1

foreach ($_POST as $key => $value)我有这样的变量 title_1、title_2、title_3 之后。我需要使 $title 等于 $title_ + $id

我试过的

            $link = ${$title_ . $id};
            $title= $title_[$id];
            $title= $title_[$id];

编码

foreach ($_POST as $key => $value)
    {
     if (preg_match('/^id_(\d*)$/', $value, $matches))
        {
    $id = $matches[1];
        if (isset($_POST['title_' . $id]))
            {
                //$link = ${$title_ . $id};
                $title= $title_[$id];
                //mysql_query("UPDATE table SET title='" . $title . "' where id='$id'");

            }
    }
    }

}
4

1 回答 1

7

你想要类似...

$link = ${$title."_" . $id};

也许

${"title_" . $id};

看到这个参考: http: //php.net/manual/en/language.variables.variable.php

于 2013-04-04T19:35:27.987 回答