多个数组转换成字符串
本帖最后由 mail163lc 于 2013-01-25 11:55:19 编辑 数组
<br />$a=Array ( [0] => 1 [1] => 2 ) <br />$b=Array ( [0] => 1 [1] => 2 ) <br />$c=Array ( [0] => 128 [1] => 108 ) <br />$d=Array ( [0] => 128 [1] => 216 )<br />
登录后复制
需要转化成的字符串
$e=1|1|128|128|~2|2|108|216
数组可能还会加
<br />$a=Array ( [0] => 1 [1] => 2 [2] => 3 ) <br />$b=Array ( [0] => 1 [1] => 2 [2] => 2 ) <br />$c=Array ( [0] => 128 [1] => 108 [2] => 420 ) <br />$d=Array ( [0] => 128 [1] => 216 [2] => 840 )<br />
登录后复制
转换的结果就需要编程
$e=1|1|128|128|~2|2|108|216|~3|2|420|840
------解决方案--------------------$a = Array ( 0 => 1, 1 => 2, 2 => 3 );<br />$b = Array ( 0 => 1, 1 => 2, 2 => 2 );<br />$c = Array ( 0 => 128, 1 => 108, 2 => 420 );<br />$d = Array ( 0 => 128, 1 => 216, 2 => 840 );<br /><br />echo foo($a, $b, $c, $d);<br /><br />function foo() {<br /> foreach(func_get_args() as $t) {<br /> foreach($t as $i=>$v)<br /> $r[$i][] = $v;<br /> }<br /> foreach($r as $i=>$v)<br /> $r[$i] = join('<br><font color='#FF8000'>------解决方案--------------------</font><br>', $v);<br /> return join('<br><font color='#FF8000'>------解决方案--------------------</font><br>~', $r);<br />}<br />
登录后复制
1
------解决方案--------------------1
------解决方案--------------------128
------解决方案--------------------128
------解决方案--------------------~2
------解决方案--------------------2
------解决方案--------------------108
------解决方案--------------------216
------解决方案--------------------~3
------解决方案--------------------2
------解决方案--------------------420
------解决方案--------------------840