0

post 変数からカンマで区切られた数値のリストがあり、次のように出力されます。

123, 456, 789, 101, 112// 数字のカンマスペース

次に、次のコードを使用してこれらの ID を個別に処理します。

$id_string = $_POST['ids'];


$id_array = array_map('trim', explode(',', $id_string));

    foreach ($id_array as $value){
        $url = 'http://myserver.com';
        $data = array('a' => $value, 'reStock' => 'true');
        $get = array();

            foreach($data as $k => $v){
            $get[] = $k . '=' . urlencode($v);
            }

            $get = implode('&', $get);

            $opts = array('http' =>
            array(
            'method'  => 'GET',
            'header'  => 'Content-type: application/x-www-form-urlencoded',
            'content' => $get
            )
            );

        $context = stream_context_create($opts);
        $mxsendstock = file_get_contents($url, false, $context);
    }

午後中ずっとテストした後、foreach を動作させることができません - 何も起こりません。私が見ることができる唯一の考えられる原因は、カンマ区切りのリストを正しく処理しているかどうかです。

何か案は?

4

1 に答える 1