我在$members
array(3) {
[0]=> array(2) {
["index"]=> string(1) "1"
["routePartitionName"]=> string(20) "US-555-foop-GWRoutes" }
[1]=> array(2) {
["index"]=> string(1) "2"
["routePartitionName"]=> string(27) "Cluster DN Presence Allowed" }
[2]=> array(2) {
["index"]=> string(1) "3"
["routePartitionName"]=> string(26) "Cluster DN Presence Denied" }
}
我试图在foreach循环中将它嵌入到另一个数组中。但是,它似乎将$members
变量评估为文本。
$programTags[] = array(
"name"=>"$cssname",
"description"=>"$cssdescription",
"members"=>"$members");
如何扩展变量,从而创建多维数组?
答案 0 :(得分:1)
Remove the quotes from $members variable, it convert it into string.
$programTags[] = array(
"name"=>"$cssname",
"description"=>"$cssdescription",
"members"=>$members);
答案 1 :(得分:0)
使用嵌套的$output .= '<div>'.$rN.'</div>';
foreach
exapmple:
foreach($members as $array)
{
//$array is array variable .
foreach($array as $values)
{
//your code here
}
}
然后再宣布$member = array(3) {
[0]=> array(2) {
["index"]=> string(1) "1"
["routePartitionName"]=> string(20) "US-555-foop-GWRoutes" }
[1]=> array(2) {
["index"]=> string(1) "2"
["routePartitionName"]=> string(27) "Cluster DN Presence Allowed" }
[2]=> array(2) {
["index"]=> string(1) "3"
["routePartitionName"]=> string(26) "Cluster DN Presence Denied" }
}
,
foreach