出于某种原因,我无法确定为什么空数组键不是unset
. 这是我所拥有的...
PHP
<?php
$attachments = explode('|',$_POST['post_attachments']);
foreach($attachments as $k=>$v)
{
echo 'k = \''.$v."'\n";
if ($v=='')
{
unset($k);
}
}
print_r($attachments);die();
?>
输出
k = ''
k = 'secret_afound.gif'
k = 'secret_aunlocked.gif'
大批 (
[0] => [1] => secret_afound.gif [2] => secret_aunlocked.gif
)