gpt4 book ai didi

php - 链接两个数组,并像MySQL DB一样使用它们

转载 作者:塔克拉玛干 更新时间:2023-11-03 05:55:03 27 4
gpt4 key购买 nike

我试图帮助一个伴侣,她坚持使用数组,所以这次没有使用数据库:(
县页面显示所有县,点击后会转到显示该县步行的不同页面。

$countys = array();
$countys[101] = array(
"name" => "Armagh",
"img" => "css/images/map.jpg",
"largeimg" => "css/images/banmap.jpg"
);

$countys[102] = array(
"name" => "Antrim",
"img" => "css/images/map.jpg",
"largeimg" => "css/images/banmap.jpg"
);

$walks = array();
$walks[1] = array(
"name" => "Portadown Walk",
"county" => "Armagh",
"img" => "css/images/map.jpg",
"location" => "Portadown",
"largeimg" => "css/images/banmap.jpg"
);

$walks[2] = array(
"name" => "Antrim Walk",
"county" => "Antrim",
"img" => "css/images/map.jpg",
"location" => "Causeway"
);

多维数组是否可以正常工作,或者可以使用 for/while 循环来检查 $walk['county'] 是否等于县?

最佳答案

多维数组最适合此操作,恕我直言。

$countys[101] = array(
"name" => "Armagh",
"img" => "css/images/map.jpg",
"largeimg" => "css/images/banmap.jpg",
"walks" => array(
array(
"name" => "Portadown Walk",
"img" => "css/images/map.jpg",
"location" => "Portadown",
"largeimg" => "css/images/banmap.jpg"
),
array(
"name" => "Some other Walk",
"img" => "css/images/map.jpg",
"location" => "Somewhere else",
"largeimg" => "css/images/banmap.jpg"
)
)
);

关于php - 链接两个数组,并像MySQL DB一样使用它们,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15889413/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com