Home > Backend Development > PHP Tutorial > 求好手帮忙写下,读取配置文件,利用编号显示

求好手帮忙写下,读取配置文件,利用编号显示

WBOY
Release: 2016-06-13 12:02:22
Original
1010 people have browsed it

求高手帮忙写下,读取配置文件,利用编号显示

<br />1巴西 VS 克罗地亚=3:0<br />2墨西哥 VS 喀麦隆=1:1<br />3西班牙 VS 荷兰=2:1<br />4智利 VS 澳大利亚=0:1<br />5<br />6<br />7<br />8<br />9<br />
Copy after login


配置文件如上,
访问1.php?id=1则输出3:0
访问1.php?id=2则输出1:1

等等,求高手帮忙写个例子




------解决方案--------------------
$ar = file('你的配置问题');<br />$v = $ar[$_GET['id']-1];<br />preg_match('/\=(.+)$/', $v, $m);<br />echo $m[1];
Copy after login

------解决方案--------------------
<br />$content = file_get_contents('f.txt');<br />$data = explode("\n", $content);<br />$id = isset($_GET['id'])? $_GET['id'] : 0;<br /><br />if(isset($data[$id-1])){<br />	echo substr(strstr($data[$id-1],'='),1);<br />}<br />
Copy after login

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template