This is to delete an array smaller than 123. I did the experiment and the result was not good. how can I change it? Elements of the array that will not be deleted while learning and researching... {code...}. this is to delete elements smaller than 123 in the array,
I'm not doing this experiment. how can I change it?
Elements of arrays that are not deleted while learning and researching ..
$ Arr = Array (1, 2, 3713231987,3710001690, 371318yb3714441990, 3713231932); user_array_filter ($ arr, 'myg', 123); echo'';print_r($arr);echo '
'; Function user_array_filter (& $ array, $ callback) {$ args = func_get_args (); // save all function parameters as an array; if (count ($ args) <2) exit ('function user_array_filter () Parameter error. there are at least two parameters. '); if (count ($ args) = 2) {foreach ($ array as $ k => $ v) {$ result = $ callback ($ v ); if (! $ Result) {return false ;//★★★★★★★★★★★★★★★★★★★★★★}}} Else {$ limit = $ args [2]; // [0]-> process an array, [1]-> function, [2]-> value foreach ($ array as $ k => $ v) {$ result = $ callback ($ v, $ limit); if (! $ Result) {return false ;//★★★★★★★★★★★★★★★★★★★★★★}}} Function myGt ($ val, $ limit = 88) {if ($ val >=$ limit) return true; return false ;}
Reply content:
This is to delete less than 123 of the array,
I'm not doing this experiment. how can I change it?
Elements of arrays that are not deleted while learning and researching ..
$ Arr = Array (1, 2, 3713231987,3710001690, 371318yb3714441990, 3713231932); user_array_filter ($ arr, 'myg', 123); echo'';print_r($arr);echo '
'; Function user_array_filter (& $ array, $ callback) {$ args = func_get_args (); // save all function parameters as an array; if (count ($ args) <2) exit ('function user_array_filter () Parameter error. there are at least two parameters. '); if (count ($ args) = 2) {foreach ($ array as $ k => $ v) {$ result = $ callback ($ v ); if (! $ Result) {return false ;//★★★★★★★★★★★★★★★★★★★★★★}}} Else {$ limit = $ args [2]; // [0]-> process an array, [1]-> function, [2]-> value foreach ($ array as $ k => $ v) {$ result = $ callback ($ v, $ limit); if (! $ Result) {return false ;//★★★★★★★★★★★★★★★★★★★★★★}}} Function myGt ($ val, $ limit = 88) {if ($ val >=$ limit) return true; return false ;}
Change the else in user_array_filter to the following code:
Else {$ limit = $ args [2]; // [0]-> process arrays, [1]-> function, [2]-> value foreach ($ array as $ k => $ v) {$ result = $ callback ($ v, $ limit); if (! $ Result) {unset ($ array [$ k]) ;}}
Ps: If you want to delete array elements, you can foreach the array and then drop the entire key unset () if the conditions are not met in the loop.