Home >Backend Development >PHP Tutorial >Problem with php post receiving.

Problem with php post receiving.

WBOY
WBOYOriginal
2016-08-04 09:19:521594browse

HTML 向PHP post一条数据 $_POST['pic'];
其中数据为http://www.baidu.com/1.pic;ht...等等
如何循环这条语句 每个$pic获取一条地址

<code> array('image_src' => $pic, 'image_name' => '随机字符串.jpg'),
);</code>

回复内容:

HTML 向PHP post一条数据 $_POST['pic'];
其中数据为http://www.baidu.com/1.pic;ht...等等
如何循环这条语句 每个$pic获取一条地址

<code> array('image_src' => $pic, 'image_name' => '随机字符串.jpg'),
);</code>

HTML

<code class="html"><form action="http://www.godruoyi.com/" method="get">
    
    <input type="text" name="pic[]">
    <input type="text" name="pic[]">
    <input type="text" name="pic[]">
    <input type="text" name="pic[]">

    <input type="submit" name="save">
</form></code>

php

<code class="php">    $pics = $_GET['pic'];
    $data = [];
    foreach ($pics as $key => $value) {
        $data[] = [
            'image_src'  =>$value,
            'image_name' => mt_rand(1, 1111) . '.jpg'
        ];
    }

    //over</code>

pic[]=XXX.jpg&pic[]=XXX.jpg

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn