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

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -