"爱爱啊","bbb"=>"比比比","ccc"=>"次次次"); 请问该怎么转,才学PHP,希望帮哈忙,多谢! ------解决方案---------"/> "爱爱啊","bbb"=>"比比比","ccc"=>"次次次"); 请问该怎么转,才学PHP,希望帮哈忙,多谢! ------解决方案---------">
Home > Backend Development > PHP Tutorial > 怎么变成键名和值

怎么变成键名和值

WBOY
Release: 2016-06-13 12:56:55
Original
733 people have browsed it

如何变成键名和值
我文本里有这样的数据:
aaa|爱爱啊
bbb|比比比
ccc|次次次
我想转成
array=("aaa"=>"爱爱啊","bbb"=>"比比比","ccc"=>"次次次");

请问该怎么转,才学PHP,希望帮哈忙,多谢!


------解决方案--------------------
$arr=file('1.txt');<br />
foreach($arr as $v){<br />
     $t=explode('<br><font color='#FF8000'>------解决方案--------------------</font><br>',$v);<br />
	 $ar[$t[0]]=$t[1];<br />
}<br />
print_r($ar);
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