我有,我有名字的列表的頁面test.php的:PregMach用PHP GET方法
name1='992345'
name2='332345'
name3='558645'
name4='434544'
在test1.php?id=name2
另一個頁面,其結果應該是:
我已經試過這PHP代碼:
<?php
$Text=file_get_contents("test.php")
$id = $_GET["id"];
;preg_match_all('/$id.=\'([^\']+)\'/',$Text,$Match);
$fid=$Match[1][0];
echo $fid; ?>
如果代碼是用這樣的
<?php
$Text=file_get_contents("test.php")
;preg_match_all('/name3=\'([^\']+)\'/',$Text,$Match);
$fid=$Match[1][0];
echo $fid; ?>
結果是好的
但我wanto能的'/name3=\'
的名字從;preg_match_all('/name3=\'([^\']+)\'/',$Text,$Match)
用GET方法樣改變這個如果test1.php?id=name4
結果將會是蜜蜂434544
。
'preg_match_all( 「/ $ ID = '([^'] +)'/」,$文本,$匹配); ' – Winston 2013-04-30 07:13:52
你可能想'urldecode($ _ GET ['id']);'去除編碼的字符,例如'+'和'preg_quote($ id)'以防'id'包含正則表達式字符。 \ + *? [^] $(){} =! < > | : - – Waygood 2013-04-30 07:15:49