doutong1890
2018-04-18 19:10
浏览 331
已采纳

将数组数组值存储在一个逗号分隔的字符串中

I have this return array

 $leaseArray =  Array ( [0] => Array ( [LeaseNumber] => OL/2011/0343 ) [1] => Array ( [LeaseNumber] => 184 ) [2] => Array ( [LeaseNumber] => OL/2011/0118 ) [3] => Array ( [LeaseNumber] => OL/2016/1759 ) [4] => Array ( [LeaseNumber] => OL/2013/0858 ) [5] => Array ( [LeaseNumber] => OL/2012/0535 ) [6] => Array ( [LeaseNumber] => OL/2017/2208 ) [7] => Array ( [LeaseNumber] => 2355 ) )

I want to save all the values of LeaseNumber in to one comma separated string like $string = "OL/2011/0343 , 184 , OL/2011/0118 , OL/2016/1759"

please help me

$lease = array();
        for($i=0;$i<=count($leaseArray); $i++){
            $lease = $leaseArray[$i]['LeaseNumber'];
        }

图片转代码服务由CSDN问答提供 功能建议

我有这个返回数组

  $ leaseArray = Array(  [0] =&gt;数组([LeaseNumber] =&gt; OL / 2011/0343)[1] =&gt;数组([LeaseNumber] =&gt; 184)[2] =&gt;数组([LeaseNumber] =&gt;  OL / 2011/0118)[3] =&gt;数组([LeaseNumber] =&gt; OL / 2016/1759)[4] =&gt;数组([LeaseNumber] =&gt; OL / 2013/0858)[5] =  &gt;数组([LeaseNumber] =&gt; OL / 2012/0535)[6] =&gt;数组([LeaseNumber] =&gt; OL / 2017/2208)[7] =&gt;数组([LeaseNumber] =&gt;  2355))
   
 
 

我想将LeaseNumber的所有值保存到一个逗号分隔的字符串 like $ string =“OL / 2011/0343, 184,OL / 2011/0118,OL / 2016/1759“

请帮助我

  $ lease = array  (); 
 for($ i = 0; $ i&lt; = count($ leaseArray); $ i ++){
 $ lease = $ leaseArray [$ i] ['LeaseNumber']; 
} 
   
 
  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

3条回答 默认 最新

相关推荐 更多相似问题