PHP disposal of multiple arrays

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.