Home  >  Article  >  Backend Development  >  PHP splits string and loops output_PHP tutorial

PHP splits string and loops output_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:14:561426browse

A simple PHP method to split a string and output it in a loop. You can refer to the study notebook.

Example 1

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

Output: 0.472347127 1.893372115 2.850965403

Example 2

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

Output: 893372115 472347127 850965403 PHP
Loop to read array variable values, similar to the usage of Split in ASP

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/628917.htmlTechArticleA simple php splits the string and loops out the study notebook for your reference. Example 1 The code is as follows Copy the code ?php $test='472347127,893372115,850965403'; $r=explode(,...
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