Welcome Guest, Not a member yet? Register   Sign In
possible error in _ci_load_class code from system//libraries/Loader.php
#1

[eluser]Peter Drinnan[/eluser]
I'm looking at the code for getting the subdir and the use of the implode function doesn't make sense:

$subdir = '';

if (strpos($class, '/') !== FALSE)
{
// explode the path so we can separate the filename from the path
$x = explode('/', $class);

// Reset the $class variable now that we know the actual filename
$class = end($x);

// Kill the filename from the array
unset($x[count($x)-1]);

// Glue the path back together, sans filename
$subdir = implode($x, '/').'/';

}

When using the PHP implode function, the delimiter should be the first parameter and the array the second, but in the code above that is reversed. Is there something I'm missing here or is this an error in the code?

Thanks.
#2

[eluser]davidbehler[/eluser]
Code:
$pieces = array('test', 'test2', 'test3');
$glue = ' - ';
        
echo implode(pieces, $glue);
echo '<br/>';
echo implode($glue, $pieces);

I just gave it a try and both give the same result: test - test2 - test3

Maybe this is some undocumented behaviour of the implode function? Don't know. It seems to work as long as one of the parameters is a string and the other is an array. Both being arrays or both being strings doesn't work.
#3

[eluser]Peter Drinnan[/eluser]
[quote author="waldmeister" date="1278905835"]

I just gave it a try and both give the same result: test - test2 - test3

Maybe this is some undocumented behaviour of the implode function? Don't know. It seems to work as long as one of the parameters is a string and the other is an array. Both being arrays or both being strings doesn't work.[/quote]


Good to know! I guess that implode PHP function is smart to interpret the field types.
#4

[eluser]WanWizard[/eluser]
This behaviour is documented in the PHP manual: "Note: implode() can, for historical reasons, accept its parameters in either order."




Theme © iAndrew 2016 - Forum software by © MyBB