二组数据分割成字符串以“,”隔开,该如何解决
程序员文章站
2022-05-21 20:07:35
...
二组数据分割成字符串以“,”隔开
Array
(
[0] => Array
(
[mobile] => 13814002394
)
[1] => Array
(
[mobile] => 13814002395
)
[2] => Array
(
[mobile] => 13814002396
)
[3] => Array
(
[mobile] => 13814002397
)
[4] => Array
(
[mobile] => 13814002398
)
[5] => Array
(
[mobile] => 13814002399
)
[6] => Array
(
[mobile] => 13814002400
)
)
这是得出的二组数组,我想分割成字符串 $mobile=13814002399,13814002400,13814002398;
这样只的形式
Array
(
[0] => Array
(
[mobile] => 13814002394
)
[1] => Array
(
[mobile] => 13814002395
)
[2] => Array
(
[mobile] => 13814002396
)
[3] => Array
(
[mobile] => 13814002397
)
[4] => Array
(
[mobile] => 13814002398
)
[5] => Array
(
[mobile] => 13814002399
)
[6] => Array
(
[mobile] => 13814002400
)
)
这是得出的二组数组,我想分割成字符串 $mobile=13814002399,13814002400,13814002398;
这样只的形式
$array=array(
'0'=>array('mobile'=>'13814002394'),
'1'=>array('mobile'=>'13814002395'),
'2'=>array('mobile'=>'13814002396'),
'3'=>array('mobile'=>'13814002397'),
'4'=>array('mobile'=>'13814002398'),
'5'=>array('mobile'=>'13814002399'),
'6'=>array('mobile'=>'13814002400')
);
foreach($array as $key=>$value){
$newarray[$key]=$value['mobile'];
}
return join(",",$newarray);
$array=array(
'0'=>array('mobile'=>'13814002394'),
'1'=>array('mobile'=>'13814002395'),
'2'=>array('mobile'=>'13814002396'),
'3'=>array('mobile'=>'13814002397'),
'4'=>array('mobile'=>'13814002398'),
'5'=>array('mobile'=>'13814002399'),
'6'=>array('mobile'=>'13814002400')
);
foreach($array as $key=>$value){
$mobile.=$dot.$value['mobile'];
$dot=",";
}
return $mobile;
相关文章
相关视频