内部数组中的所有项目是否更简单?
$user = array(
'name' => 'Joe Blogs',
'age' => 25,
'validate' => 'true',
'children' => array(
'Jack',
'Jill',
'Mark')
);
echo "The user's details are: " . $user['children'][0] .' '. $user['children'][1] .' and '. $user['children'][2];
答案 0 :(得分:1)
利用implode()
<?php
$user = array(
'name' => 'Joe Blogs',
'age' => 25,
'validate' => 'true',
'children' => array(
'Jack',
'Jill',
'Mark')
);
echo "The user details are ".implode(',',$user['children']);
<强> OUTPUT :
强>
The user details are Jack,Jill,Mark