Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
这是一个非常菜鸟的问题。以前的开发人员已对以下行进行了编码
$a = array("30"=>"ok","40"=>"yes"); $b = "hi"; $c = $a."|".$b; $d = explode("|",$c); print_r($d[0]);
如何显示数组array("30"=>"ok","40"=>"yes")?print_r($d[0]);似乎只是打印array
array("30"=>"ok","40"=>"yes")
print_r($d[0]);
array
这打印“ array”而不是实际的数组值是因为这一行:
$c = $a."|".$b;
你在做什么是说:
$c = [array] + [string] + [string];
这将强制array转换为 a string,这只是“数组”
string
如果你真的想要一个|单独的数组索引字符串,理论上你可以这样做:
|
$c = implode("|",$a)."|".$b;
但这里真正的最佳解决方案是在爆炸数组之前向数组添加一些内容:
$a['50'] = 'hi'; $d = explode("|", $c);