Home > php教程 > php手册 > body text

php分割字符串并循环输出

WBOY
Release: 2016-06-13 10:15:44
Original
1731 people have browsed it

一个简单的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用法

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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template