urlencode と urldecode を使用して、変数を html フォームに渡します。
$info = 'tempId='.$rows['tempID'].'&tempType='.$rows['tempType'].'&dbId='.$rows['ID'];
echo '<input type="hidden" name="rank[]" value="'.urlencode($info).'" >';
$rows の内容は次のとおりです
array (size=4)
'ID' => string '110' (length=3)
'tempID' => string '1' (length=1)
'tempType' => string 'temp_first' (length=10)
'pageOrder' => string '0' (length=1)
だから $info は
tempId=1&tempType=temp_first&dbId=110
しかし、それをデコードすると、1 つのパラメーターが失われます。これはどのように可能ですか?
foreach (explode('&', urldecode($list[$i])) as $chunk) {
$param = explode("=", $chunk);
$tempId = urldecode($param[0]); // template id
$tempType = urldecode($param[1]); // Template type
$dbId = urldecode($param[2]); // database ID
var_dump($param);
}
出力:
array (size=2)
0 => string 'dbId' (length=4)
1 => string '110' (length=3)
たとえば、temp_first の代わりに tempType と表示されているなど、配列内にあるべきではないものさえある場合があります。変数名だけ。
皆さんが私を助けてくれることを願っています