Searching and deleting from an array???
Posted 17 September 2006 - 01:51 AM
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)???
Posted 17 September 2006 - 06:19 AM
<?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); ?>
Posted 17 September 2006 - 12:11 PM
thanks thats great just what i wanted. But as i am new to php could you explain what the line -
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?
Posted 17 September 2006 - 12:20 PM
when you use the code below your only see one echoed redarrow
as the seconed ecohed redarrow is unset.
<?php // name is redarrow $name="redarrow"; /// echo the name redaarow echo $name; //unset varable $name what was redarrow unset($name); // echo name now nothink why becouse we unset the varable........ echo $name; ?>
((EMAIL CODE THAT WORKS))
((PAYPAL INTEGRATION THAT WORKS))
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users