eng_coo Posted September 17, 2006 Share Posted September 17, 2006 Hi,i know its possible to delete first and last values from an array but is it possible to delete a specific value from an array (possibly a user search to delete a certain value)???cheers john Link to comment https://forums.phpfreaks.com/topic/21031-searching-and-deleting-from-an-array/ Share on other sites More sharing options...
sasa Posted September 17, 2006 Share Posted September 17, 2006 try[code]<?php$a=array('sasa','qwe','poi');print_r($a);$remowe = 'qwe';echo "\n<hr /> Remove element $remowe\n\n";unset($a[array_search($remowe,$a)]);print_r($a);?>[/code] Link to comment https://forums.phpfreaks.com/topic/21031-searching-and-deleting-from-an-array/#findComment-93408 Share on other sites More sharing options...
eng_coo Posted September 17, 2006 Author Share Posted September 17, 2006 Hi,thanks thats great just what i wanted. But as i am new to php could you explain what the line -unset($a[array_search($remowe,$a)]);means. i know it searches the array for the value but, i have never come across 'unset' before. is it basically just delete from varible $a and can it only be used with arrays?thanksjohn Link to comment https://forums.phpfreaks.com/topic/21031-searching-and-deleting-from-an-array/#findComment-93446 Share on other sites More sharing options...
redarrow Posted September 17, 2006 Share Posted September 17, 2006 unset is to unset() a varablewhen you use the code below your only see one echoed redarrowas the seconed ecohed redarrow is unset.good luck.[code]<?php// name is redarrow$name="redarrow";/// echo the name redaarowecho $name;//unset varable $name what was redarrowunset($name);// echo name now nothink why becouse we unset the varable........echo $name;?>[/code] Link to comment https://forums.phpfreaks.com/topic/21031-searching-and-deleting-from-an-array/#findComment-93447 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.