How to make this backwards compatible with PHP5.2? It works on 5.3 and later
Fatal error: Cannot call method self::utf8_dec() or method does not exist
private function utf8_decode($arr){
array_walk_recursive($arr, 'self::utf8_dec'); // <----- error
return $arr;
}
private function utf8_dec(&$value, $key){
$value = utf8_decode($value);
}
Instead of self
, you can use the name of the class directly. It's not as flexible but it should work.
static private function utf8_decode($arr){
array_walk_recursive($arr, 'YourClass::utf8_dec');
return $arr;
}
static private function utf8_dec(&$value, $key){
$value = utf8_decode($value);
}
Also you need to prefix the methods with the static
keyword.