好吧。我有一个这样定义的填充数组:
$subs = array();
for (...) {
// extracting of variables $knowledgeLevel, $name, $short, $long
$subs [] = array (
'knowledgeLevel' => $knowledgeLevel,
'name' => $name,
'shortTheory' => $short,
'longTheory' => $long
);
}
然后我收到一个值$kl
,我想最终从数组$subs
中element
删除knowledgeLevel
等于$kl
。我试过这样做:
foreach ( $subs as $subject ) {
if ($subject['knowledgeLevel'] == $kl) {
unset ($subject);
}
}
所以
foreach ( $subs as $subject ) {
if ($subject['knowledgeLevel'] == $kl) {
unset ($subject['knowledgeLevel']);
unset ($subject['name']);
unset ($subject['shortTheory']);
unset ($subject['longTheory']);
}
}
但这些似乎不起作用。