PHP changes to a loop traversal.

Source: Internet
Author: User
{Code ...} this can only be read one by one. The front-end must submit multiple images in the format of www.baidu.com1.jpg or gif. I used another method to obtain all image addresses, the format is as follows {code ...} how can I make it traverse the style I want in php?
    $imagee = $_GET['pic'];        foreach ($imagee as $k => $v) {         $image[]= array(                'image_src'  =>$v,                'image_name' => mt_rand(1, 1111) . '.jpg'            );        }

This can only be read by one row. the front-end must submit multiple pic records.
Each entry is in the following format:http://www.baidu.com/1.jpgOrgif
I used another method to get all the image addresses in the following format:

Bytes

How can I make it traverse the style I want in php?

Reply content:
    $imagee = $_GET['pic'];        foreach ($imagee as $k => $v) {         $image[]= array(                'image_src'  =>$v,                'image_name' => mt_rand(1, 1111) . '.jpg'            );        }

This can only be read by one row. the front-end must submit multiple pic records.
Each entry is in the following format:http://www.baidu.com/1.jpgOrgif
I used another method to get all the image addresses in the following format:

Bytes

How can I make it traverse the style I want in php?

Traverse to the style you want? Style. If I guess what you mean by mistake, then yesexplode?

// Assume that the delimiter is _ (two English underlines) $ pic = "http://www.baidu.com/1.jpg__http://www.baidu.com/2.jpg__http://www.baidu.com/3.jpg"; $ arr = explode ('_', $ pic ); foreach ($ arr as $ key =>$ v) {unset ($ arr [$ key]); $ arr [$ key] ['image _ src'] = $ v; $ arr [$ key] ['image _ name'] = mt_rand (1, 11112.16.'.jpg ';} print_r ($ arr );

I don't know if I don't understand what it means. I feel that it is not much different from the landlord's code, but there is only one moreexplode

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.