Welcome Guest, Not a member yet? Register   Sign In
Read/Load all php files with a certain ending?
#2

[eluser]SpooF[/eluser]
Place this below the $autoload['helper'] = array('');

Or if you want this in a contructor you can change it a bit to use the $this->load->helper() function. Let me know if you need help to alter it.

Code:
$handle = opendir(APPPATH.'helpers');

if ( $handle )
{
        while ( false !== ($helper = readdir($handle)) )
        {
                // make sure we don't map silly dirs like .svn, or . or ..

                if ( substr($helper, 0, 1) != "." )
                {
                    $pattern = '/^([a-zA-Z0-9])+(_help\.php)/'; # This should work, you can edit `_help\.php` to change the ending tag of your file, it currently matches anything with _help.php on the end.
                    if ( preg_match($pattern,$helper) )
                    {
                        $h_array = substr($helper,0,-4);
                    }
                }
        }
}

$autoload['helper'] = array_push($autoload['helper'],$h_array);

Basically what this will do is read your helpers folder for all its files, then it will check to see if the file name matches your format. If it does it adds it to an array and after the script goes through all the files it combines it with what ever other helpers you already have selected to load.

I'll see if I can get back to you on the expression. I just need to find the manual online.


Messages In This Thread
Read/Load all php files with a certain ending? - by El Forum - 08-07-2008, 07:32 AM
Read/Load all php files with a certain ending? - by El Forum - 08-07-2008, 10:41 AM
Read/Load all php files with a certain ending? - by El Forum - 08-07-2008, 03:04 PM
Read/Load all php files with a certain ending? - by El Forum - 08-07-2008, 03:31 PM
Read/Load all php files with a certain ending? - by El Forum - 08-07-2008, 11:54 PM
Read/Load all php files with a certain ending? - by El Forum - 08-08-2008, 12:33 AM
Read/Load all php files with a certain ending? - by El Forum - 08-08-2008, 12:51 AM
Read/Load all php files with a certain ending? - by El Forum - 08-08-2008, 01:22 AM
Read/Load all php files with a certain ending? - by El Forum - 08-08-2008, 01:25 AM
Read/Load all php files with a certain ending? - by El Forum - 08-08-2008, 01:53 AM
Read/Load all php files with a certain ending? - by El Forum - 08-08-2008, 02:09 AM
Read/Load all php files with a certain ending? - by El Forum - 08-08-2008, 02:56 AM
Read/Load all php files with a certain ending? - by El Forum - 08-08-2008, 04:05 AM
Read/Load all php files with a certain ending? - by El Forum - 08-08-2008, 04:20 AM
Read/Load all php files with a certain ending? - by El Forum - 08-08-2008, 04:34 AM
Read/Load all php files with a certain ending? - by El Forum - 08-08-2008, 04:44 AM
Read/Load all php files with a certain ending? - by El Forum - 08-08-2008, 06:29 AM
Read/Load all php files with a certain ending? - by El Forum - 08-08-2008, 06:41 AM
Read/Load all php files with a certain ending? - by El Forum - 08-10-2008, 10:06 AM
Read/Load all php files with a certain ending? - by El Forum - 08-10-2008, 11:02 AM
Read/Load all php files with a certain ending? - by El Forum - 08-10-2008, 01:27 PM
Read/Load all php files with a certain ending? - by El Forum - 08-10-2008, 02:15 PM



Theme © iAndrew 2016 - Forum software by © MyBB