PHP changes to a loop traversal.

Source: Internet
Author: User
    $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 one line, the front desk to submit multiple pic
Each format is: http://www.baidu.com/1.jpg orgif
I used another method to get all the image addresses, formatted as follows

 http://www.baidu.com/1.jpg分隔符http://www.baidu.com/2.jpg分隔符http://www.baidu.com/3.jpg

How do I get it to traverse through PHP into the style I want?

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 one line, the front desk to submit multiple pic
Each format is: http://www.baidu.com/1.jpg orgif
I used another method to get all the image addresses, formatted as follows

 http://www.baidu.com/1.jpg分隔符http://www.baidu.com/2.jpg分隔符http://www.baidu.com/3.jpg

How do I get it to traverse through PHP into the style I want?

Walk into the style you want? What style. If I'm wrong about what you mean, then explode ?

//这里假设分割符是__(两个英文下划线)$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, 1111).'.jpg';}print_r($arr);

Do not know whether I did not understand the meaning, and the landlord's code is not a big difference ah, just 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.