The following code works differently in PHP 4 and PHP 5.
<?php
array_walk($tagmarks, create_function('&$a',
'if(isset($a[\'tag_array\'])){
array_walk($a[\'tag_array\'],\'resolveTitle\');
sortTags($a[\'tag_array\']);
}'));
?>
Here's resolveTitle and sortTags:
<?php
function resolveTitle(&$tag){ #used for callbacks
$tag['title'] = formatTitle($tag);
}
function sortTags(&$tags){
usort($tags, 'compareTags');
}
function compareTags($a,$b){
#accounts for if the titles are the same, and then sorts by tag
return $a['title'] == $b['title'] ?
strcmp($a['tag'],$b['tag']) :
strnatcasecmp($a['title'],$b['title']);
}?>
(Some code reformatted to wrap.) In PHP 5, the code only handles the first instance of a 'tag_array', whereas on 4 it does what it should. AFAICT this code isn't hitting any known problem areas of PHP 5 (such as object references), so, without doing more analysis, the only thing I can blame the difference on is a bug in PHP 5. Maybe the array_walk nesting does it?
I'm sticking this here largely because I'm going to change the code to make it work in PHP 5, and I want a record of it. I don't have time now to A) go through the PHP CVS looking for changes that would cause this B) play with this to isolate what's broken. Anyone have any idea what's making this code break?
new⇒Court rejects death penalty for raping children - Yahoo! News
:)...
Keith: Jul 4, 11:32am