我想将所有会话的键和值转换为字符串。当我运行此代码时:
<?php
session_start();
error_reporting(E_ALL);
ini_set('display_errors', 1);
$array['language'] = 'Asdfgh';
$array['currency'] = 'Asdfgh';
$array['cart'][] = 'Asdfgh';
$array['cart'][] = 'Asdfgh';
$array['facebookpagelikeshowed'] = 'Asdfgh';
$array['vid_yMHe4j2Ouko']['uid'] = '170785079';
$array['vid_yMHe4j2Ouko']['vid'] = '170785079';
$text = '';
foreach ($array as $key => $value)
{
$text .= ''.$key.'='.$value.';';
}
echo $text;
?>
我收到了这个错误:
Notice: Array to string conversion in /var/www/index.php on line 16
为什么呢?我该如何解决?
答案 0 :(得分:0)
问题是foreach到达$ key vid_yMHe4j2Ouko
$的值是array
类型,因此您无法使用concat运算符(. $value
)