通过explode函数分割字符串成数组,如何让索引从1开始
通过explode函数分割字符串成数组,如何让索引从1开始
------解决方案--------------------
<?php $str = "1,2,3,4,5,6";$a = explode(',',$str);$b = Array();foreach($a as $key=>$val){ $b[$key+1] = $val;}print_r($a);print_r($b);?><div class="clear"> </div>