时间:2021-07-01 10:21:17 帮助过:8人阅读
到前台我想要的结果是
1) { $new_arr[]=explode('|',$value); } } echo ""; print_R($new_arr); echo "";?>
简单的写了下,凑合着能,不知道有没有什么更好的办法
Array( [0] => Array ( [0] => 2013-09-09 00:00:22 [1] => 13814002394 [2] => 内容 ) [1] => Array ( [0] => 2013-09-09 00:00:19 [1] => 13814002394 [2] => 内容 ) [2] => Array ( [0] => 2013-09-07 00:51:57 [1] => 15920531400 [2] => 内容 ) [3] => Array ( [0] => 2013-09-06 22:21:02 [1] => 15920531400 [2] => 内容
$s =<<< TXT9||50||1|#|2013-09-09 00:00:22||13814002394||内容||1|#|2013-09-09 00:00:19||13814002394||内容||1|#|2013-09-07 00:51:57||15920531400||内容||1|#|2013-09-06 22:21:02||15920531400||内容||1|#|2013-09-06 22:13:14||15920531400||内容||1|#|2013-09-06 22:07:42||15920531400||内容||1|#|2013-09-05 14:00:02||15920531400||内容||1|#|2013-09-05 12:10:13||15920531400||内容||1|#|2013-09-05 12:01:27||15920531400||内容||1|#|TXT;preg_match_all('/\|([^|]+)\|\|([^|]+)\|\|(.*)/m', $s, $r);print_r($r);
Array( [1] => Array ( [0] => 2013-09-09 00:00:22 [1] => 2013-09-09 00:00:19 [2] => 2013-09-07 00:51:57 [3] => 2013-09-06 22:21:02 [4] => 2013-09-06 22:13:14 [5] => 2013-09-06 22:07:42 [6] => 2013-09-05 14:00:02 [7] => 2013-09-05 12:10:13 [8] => 2013-09-05 12:01:27 ) [2] => Array ( [0] => 13814002394 [1] => 13814002394 [2] => 15920531400 [3] => 15920531400 [4] => 15920531400 [5] => 15920531400 [6] => 15920531400 [7] => 15920531400 [8] => 15920531400 ) [3] => Array ( [0] => 内容 [1] => 内容 [2] => 内容 [3] => 内容 [4] => 内容 [5] => 内容 [6] => 内容 [7] => 内容 [8] => 内容 ))
$ar = array_map(function($a,$b,$c){return array($a,$b,$c);}, $r[1], $r[2], $r[3]);print_r($ar);
Array( [0] => Array ( [0] => 2013-09-09 00:00:22 [1] => 13814002394 [2] => 内容 ) [1] => Array ( [0] => 2013-09-09 00:00:19 [1] => 13814002394 [2] => 内容 ) [2] => Array ( [0] => 2013-09-07 00:51:57 [1] => 15920531400 [2] => 内容 ) [3] => Array ( [0] => 2013-09-06 22:21:02 [1] => 15920531400 [2] => 内容 ) [4] => Array ( [0] => 2013-09-06 22:13:14 [1] => 15920531400 [2] => 内容 ) [5] => Array ( [0] => 2013-09-06 22:07:42 [1] => 15920531400 [2] => 内容 ) [6] => Array ( [0] => 2013-09-05 14:00:02 [1] => 15920531400 [2] => 内容 ) [7] => Array ( [0] => 2013-09-05 12:10:13 [1] => 15920531400 [2] => 内容 ) [8] => Array ( [0] => 2013-09-05 12:01:27 [1] => 15920531400 [2] => 内容 ))
$r[0] = function(){return func_get_args();};$ar = call_user_func_array('array_map', $r);更一般些
这些结果都是二维数组啊,怎么样在前台循环出来!!!!!!!!!!!!!!!!!
MVC模式!
如果不用做其他计算,直接替换就行了,还要分数组么?
preg_replace('/^\|\|1\|#\|([^\|]+)\|\|([^\|]+)\|\|(.+)$', '