Home  >  Article  >  php教程  >  php分割字符串并循环输出

php分割字符串并循环输出

WBOY
WBOYOriginal
2016-06-13 10:15:441729browse

一个简单的php分割字符串并循环输出 学习笔记本大家可参考参考。

例子一

 代码如下 复制代码
$test='472347127,893372115,850965403';
$r=explode(",",$test);
for($i=0;$i { echo $i.".". $r[$i].""; }
?>

输出: 0.472347127 1.893372115 2.850965403

例子二

 代码如下 复制代码
$a="893372115,472347127,850965403" ;
$b=explode(",",$a);
foreach($b as $bb)
{ echo $bb.""; //print_r($b); }
?>

输出: 893372115 472347127 850965403 PHP
循环读取数组变量值,类似ASP里的Split用法

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