http://Bj83.de

Entferne Array Element anhand von Elementwerten

<?php
   function dump($val){
	print "<pre>"; 
	print_r($val);
	print "</pre>";	
   }

   $arr = array('e1'=>'w1','e2'=>'w2','e3'=>'w3','e4'=>'w4','e5'=>'w6');
   dump($arr);
   array_search('w3', $arr);
   $arr = array_diff($arr, array('w3'));
   dump($arr);
?>

Ouput:

Array
(
    [e1] => w1
    [e2] => w2
    [e3] => w3
    [e4] => w4
    [e5] => w6
)

Array
(
    [e1] => w1
    [e2] => w2
    [e4] => w4
    [e5] => w6
)

 

Leave a Reply

Your email address will not be published. Required fields are marked *

Follow

Get every new post on this blog delivered to your Inbox.

Join other followers: