PHPで文字列として読み込まれたhtmlファイルがあり、HTML文字列の入力要素の値を取得する必要があります。入力要素の名前を取り、その値を返す関数を作成するのを手伝ってくれる人はいますか?
これは私がやりたい機能の例です:
function getVal($name){
$htmlStr = "<form action = \"action.php\"><input type=\"hidden\" name=\"command\" value=\"123456\">
<input type=\"hidden\" name=\"quantity\" value=\"1\">
<input type=\"hidden\" name=\"user_mode\" value=\"1\">
<input type=\"hidden\" name=\"stock\" value=\"-1255303070\">
<input type=\"hidden\" name=\"id\" value="429762082">
<input type=\"hidden\" name=\"pidm\" value=\"2\"></form>";
// I'd like to get the value of $name here probably using preg_match
return $value; //returns 123456
}
$val = getVal("コマンド"); //val は 123456 である必要があります。
イダスは?ありがとうございました