Home >Backend Development >PHP Tutorial >请问一下,怎么把用"|"格开的字符串,猜开?

请问一下,怎么把用"|"格开的字符串,猜开?

WBOY
WBOYOriginal
2016-06-23 14:09:17963browse

$aaaa = "image/1.jpg|image/2.jpg|image/3.jpg"
请问一下,怎么把用"|"格开的字符串,猜开?
猜成下面的字符串.
$a1 = "image/1.jpg";
$a2 = "image/2.jpg";
$a3 = "image/3.jpg";

请详细一些,谢谢.


回复讨论(解决方案)

list($a1, $a2, $a3) = explode('|', $aaaa);

explode

list($a1, $a2, $a3) = explode('|', $aaaa);

正解

http://www.w3school.com.cn/php/func_string_explode.asp

了解一下这个explode函数

	$aaaa = "image/1.jpg|image/2.jpg|image/3.jpg";	$ar=explode("|",$aaaa);	echo "<pre class="brush:php;toolbar:false">";	print_r($ar);	echo "
";

Statement:
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