in function CreateDeepArray: ltrim() instead of while

Locked
j3s
User
Posts:1
Joined:Thu Nov 08, 2012 7:55 pm
Are you a spambot?:no
in function CreateDeepArray: ltrim() instead of while

Post by j3s » Thu Nov 08, 2012 8:05 pm

You can replace

Code: Select all

while ($array_path{0} == $separator) {
    $array_path = substr($array_path, 1);
}
with

Code: Select all

ltrim($array_path, $separator);
in function CreateDeepArray($array_path, $separator, $value).

This function appears in module.archive.zip.php and module.misc.iso.php and was in getid3.lib.php.

James Heinrich
getID3() v1 developer
Posts:1477
Joined:Fri May 04, 2001 4:00 pm
Are you a spambot?:no
Location:Northern Ontario, Canada
Contact:

Re: in function CreateDeepArray: ltrim() instead of while

Post by James Heinrich » Sun Nov 11, 2012 10:49 pm

Thanks. You're quite right that's a more sensible way of doing it.

In case you're wondering why it was written like that, I suspect this is most likely quite old code, and the PHP version requirements of getID3 only required PHP 4.0.6 up until Jan 2007, and the $charlist parameter of ltrim didn't appear until PHP 4.1.0

The function is also used in module.archive.rar.php and module.archive.tar.php, but it's only the single function definition to worry about in getid3.lib.php

Change will be included in v1.9.5

Locked