PHP processing of multiple arrays author: Lin Zimu wolinxuebin blog address: processing of multiple arrays in PHP
Author: Lin Zimu wolinxuebin
Blog: http://my.csdn.net/wolinxuebin
Reprinted and retained
I am writing PHP code today. to send data to the mobile phone end, the data is obtained from mysql. There is an ID number, and mysql stores the int type. it can be retrieved and found to be a string.
I checked on the internet and found that there is no ready-made solution. php is a weak type and it doesn't matter. However, the other party said, I want the int type, but I can't write it myself.
Function array_intval (& $ ar, $ key, $ base = 10) {foreach ($ ar as $ k = >$ v) {if (is_array ($ v )) {// determines whether an array exists. Always Open array_intval ($ ar [$ k], $ key, $ base );} else {return $ ar [$ key] = intval ($ ar [$ key], $ base );}}}Directly add the code.
array_intval($result, 'id');
The call is directly written like this, because the address is used to pass the value in, so no response is needed.
Other processes are similar. this can be said to be a template.