1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
<?php $val='http://mydoubts.in'; $myarray = array("0" => "http://mydoubts.in", "1" => "mytestvalue" ); print_r($myarray);echo "<br>"; $words_to_replace=$val; $myarray=searchandreplace($myarray,$words_to_replace); print_r($myarray); function searchandreplace($myarray,$words_to_replace) { foreach($myarray as $key => $val) { if ($val == $words_to_replace) $myarray[$key] = ''; } return $myarray; } ?> |