很抱歉,如果这对你们很明显,但在这里我正在努力做到:
我有以下数组:
$myArray=Array ( "024848772" ,"0550244954", "0560084252","0559180203","0673466366","021648334" ....);
我希望这样:
Array ( array("024848772"),array("0550244954"),array("0560084252"),array("0559180203"),array("0673466366"),array("021648334") ....);
答案 0 :(得分:1)
<?php
$a=array(1,2,3,4,5);
function fun($v) {
return array($v);
}
print_r(array_map("fun",$a));
答案 1 :(得分:0)
循环遍历数组并将结果添加到累加器中,将它们包装在一个数组中:
$acc = array();
foreach($myArray as $someString){
$acc[] = array($someString);
}
var_dump($acc);
沙箱here中的示例。
答案 2 :(得分:0)
试试这段代码:
$myArray=Array ( "024848772" ,"0550244954", "0560084252","0559180203","0673466366","021648334" );
$arrays = array();
foreach ($myArray as $x)
$arrays[] = array($x);
//print_r($arrays);
答案 3 :(得分:0)
没有真正看到问题。您的原始语法有效。
$ myArray = Array(array(&#34; 024848772&#34;),array(&#34; 0550244954&#34;),array(&#34; 0560084252&#34;),array(&#34; 0559180203&#34),阵列(&#34; 0673466366&#34),阵列(&#34; 021648334&#34));
的var_dump($ myArray的);