Jump to content

[SOLVED] delete from array


simon551

Recommended Posts

I know you've said "solved" on this, but here's one more way ...

 

<?php
$t = array('a1','v','2','x5','z6','v'=>'7');
$nt = array_delete('z6',$t);
echo '<pre> ' . print_r($t,true) . '</pre>';
echo '<pre> ' . print_r($nt,true) . '</pre>';

function array_delete($x, $ary) {
  if (!is_array($x)) $x = array($x);
  return(array_diff($ary,$x));
}
?>

 

Ken

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.