回复讨论(解决方案)
$array = array('你的数组');
$result = array();
foreach($array as $k1=>$v1){
foreach($v1 as $k2=>$v2){
$result[$k1][] = $v2;
}
}
echo $result;
;
不好使,输出成这样了
发一份我的数据吧,如下
array (size=2) //原先是5
0 =>
object(stdClass)[161]
public 'id' => int 1
public '时间' => string '2/16/16 16:13' (length=13)
public 'USERID' => string '5566' (length=4)
public 'UUID' => string 'U123' (length=4)
public '用户类型' => string '广告主/代理' (length=16)
public '设备' => string 'PC' (length=2)
public 'IP' => string '192.168.0.1' (length=11)
public 'URL' => string 'http://xxxx/viewpage.action?pageId=4620291' (length=56)
public 'REFERER' => string 'http://xxx/pages/' (length=26)
public '动作' => string '竞价' (length=6)
public '状态' => string '有效' (length=6)
1 =>
object(stdClass)[162]
public 'id' => int 2
public '时间' => string '2/16/16 16:13' (length=13)
public 'USERID' => string '5566' (length=4)
public 'UUID' => string 'U123' (length=4)
public '用户类型' => string '广告主/代理' (length=16)
public '设备' => string 'PC' (length=2)
public 'IP' => string '192.168.0.1' (length=11)
public 'URL' => string 'http://xxx/pages/viewpage.action?pageId=4620291' (length=56)
public 'REFERER' => string 'http://xxx/pages/' (length=26)
public '动作' => string '投放' (length=6)
public '状态' => string '无效' (length=6)
;
不好使,输出成这样了
发一份我的数据吧,如下
array (size=2) //原先是5
0 =>
object(stdClass)[161]
public 'id' => int 1
public '时间' => string '2/16/16 16:13' (length=13)
public 'USERID' => string '5566' (length=4)
public 'UUID' => string 'U123' (length=4)
public '用户类型' => string '广告主/代理' (length=16)
public '设备' => string 'PC' (length=2)
public 'IP' => string '192.168.0.1' (length=11)
public 'URL' => string 'http://xxxx/viewpage.action?pageId=4620291' (length=56)
public 'REFERER' => string 'http://xxx/pages/' (length=26)
public '动作' => string '竞价' (length=6)
public '状态' => string '有效' (length=6)
1 =>
object(stdClass)[162]
public 'id' => int 2
public '时间' => string '2/16/16 16:13' (length=13)
public 'USERID' => string '5566' (length=4)
public 'UUID' => string 'U123' (length=4)
public '用户类型' => string '广告主/代理' (length=16)
public '设备' => string 'PC' (length=2)
public 'IP' => string '192.168.0.1' (length=11)
public 'URL' => string 'http://xxx/pages/viewpage.action?pageId=4620291' (length=56)
public 'REFERER' => string 'http://xxx/pages/' (length=26)
public '动作' => string '投放' (length=6)
public '状态' => string '无效' (length=6)
我这边输出的没问题呀
Array
(
[0] => Array
(
[0] => 1
[1] => 2/16/16 16:13
)
[1] => Array
(
[0] => 2
[1] => 2/16/16 16:13
)
)
;
不好使,输出成这样了
发一份我的数据吧,如下
array (size=2) //原先是5
0 =>
object(stdClass)[161]
public 'id' => int 1
public '时间' => string '2/16/16 16:13' (length=13)
public 'USERID' => string '5566' (length=4)
public 'UUID' => string 'U123' (length=4)
public '用户类型' => string '广告主/代理' (length=16)
public '设备' => string 'PC' (length=2)
public 'IP' => string '192.168.0.1' (length=11)
public 'URL' => string 'http://xxxx/viewpage.action?pageId=4620291' (length=56)
public 'REFERER' => string 'http://xxx/pages/' (length=26)
public '动作' => string '竞价' (length=6)
public '状态' => string '有效' (length=6)
1 =>
object(stdClass)[162]
public 'id' => int 2
public '时间' => string '2/16/16 16:13' (length=13)
public 'USERID' => string '5566' (length=4)
public 'UUID' => string 'U123' (length=4)
public '用户类型' => string '广告主/代理' (length=16)
public '设备' => string 'PC' (length=2)
public 'IP' => string '192.168.0.1' (length=11)
public 'URL' => string 'http://xxx/pages/viewpage.action?pageId=4620291' (length=56)
public 'REFERER' => string 'http://xxx/pages/' (length=26)
public '动作' => string '投放' (length=6)
public '状态' => string '无效' (length=6)
把echo 换成print_r
foreach($data as $row) { foreach($row as $v) echo $v . '<br>';}
登入後複製