Home >Backend Development >PHP Tutorial > 二组数据分割成字符串以“,”隔开,该如何解决

二组数据分割成字符串以“,”隔开,该如何解决

WBOY
WBOYOriginal
2016-06-13 12:29:351080browse

二组数据分割成字符串以“,”隔开
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;

这样只的形式

<br />
$array=array(<br />
	'0'=>array('mobile'=>'13814002394'),<br />
	'1'=>array('mobile'=>'13814002395'),       <br />
	'2'=>array('mobile'=>'13814002396'),<br />
	'3'=>array('mobile'=>'13814002397'),<br />
	'4'=>array('mobile'=>'13814002398'),<br />
	'5'=>array('mobile'=>'13814002399'),<br />
	'6'=>array('mobile'=>'13814002400')<br />
);<br />
foreach($array as $key=>$value){<br />
	$newarray[$key]=$value['mobile'];<br />
}<br />
return join(",",$newarray);<br />
<br />
<br />
$array=array(<br />
	'0'=>array('mobile'=>'13814002394'),<br />
	'1'=>array('mobile'=>'13814002395'),       <br />
	'2'=>array('mobile'=>'13814002396'),<br />
	'3'=>array('mobile'=>'13814002397'),<br />
	'4'=>array('mobile'=>'13814002398'),<br />
	'5'=>array('mobile'=>'13814002399'),<br />
	'6'=>array('mobile'=>'13814002400')<br />
);<br />
foreach($array as $key=>$value){<br />
	$mobile.=$dot.$value['mobile'];<br />
	$dot=",";<br />
}<br />
return $mobile;<br />
<br />

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