zend framework - Callback functions in PHP < 5.3 -


i have multidimensional array , want usort in zendframework.**

following code work in php 5.3+, not lower versions because of callback function in usort.

usort($array, function (array $a, array $b) {     return date('ymdhis',$a['time']) - date('ymdhis',$b['time']);  }); 

so instead of callback function how can divide , use external function call in zend framework.

in normal php script individual call working below.

usort($array, 'usortcallback');  function usortcallback(array $a, array $b) {     return date('ymdhis',$a['time']) - date('ymdhis',$b['time']); }); 

but want workable code zend framework.

thanks, sandeep

you can use create_function(), fork older php too.

$callback = create_function(     '$a, $b',     'return date("ymdhis",$a["time"]) - date("ymdhis",$b["time"]);' );  usort($array, $callback); 

Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -