Utility Functions
1. Sorting with user defined comparator
In PHP -
usort($bp_radios, create_function('$a, $b',
'return $a["radio_index"] - $b["radio_index"];'));
In JS -
tabRF_apList[i]['radios'].sort(function(a,b) {
return a['radio_index'] - b['radio_index']});
2. Array <=> String with delimiter
In PHP -
$radio = implode('/', $radioNameArray); // {'a', 'b'} => 'a/b'
$radioNameArray = explode('/', $radio);
In JS -
var radio = radioNameArray.join('/');
var radioNameArray = radio.split("/");
No comments:
Post a Comment