如何拆分使用php的系列

时间:2013-03-18 08:32:31

标签: php

     Array([0] =>  1,2,3,4,5)

这是我的代码中的输入模式。我必须拆分这个值,需要输出如下

Array ( [0] => 1, [1] =>2, [2] => 3, [3] =>4, [4] =>5 )

5 个答案:

答案 0 :(得分:1)

尝试

$avalues="1,2,3,4,5";
$myarray = explode(',',$avalues);
print_r($myarray);

答案 1 :(得分:0)

尝试爆炸

$vals = explode("," $avalues);

答案 2 :(得分:0)

$avalues="1,2,3,4,5"; 
$array = explode(',',$avalues);
print_r($array);

答案 3 :(得分:0)

这可能是解决方案,

  $avalues="1,2,3,4,5"; 
  $a = explode(',',$avalues);
  var_dump($a);

答案 4 :(得分:-1)

你需要使用explode()函数来爆炸基于角色的字符串。

 $avalues      ='1,2,3,4,5';  
 $exploded_arr = explode(',' , $avalues);


 foreach($exploded_arr as $key=> $value)
 {
    $exploded_arr[$key] = $value.",";
 }

 echo "<pre>";
 print_r($exploded_arr);
 echo "</pre>";

Doucmentaiton链接:http://www.w3schools.com/php/func_string_explode.asp