Re: Simple array question, array delete

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ryan A wrote:

Hey,
I have a $data_recs array like this:

12
445
45655
4
3466663
etc

when the user gives me a number, i have to check if its in the array and
delete that entry...how do i do that?
I have looked at the manual but have gotten confused with array
pop,splice,array_key_exists etc

Thanks,
Ryan





The code follows :

if (in_array($number, $data_recs)) {
   $key = array_search($number, $data_recs); // Get the key
      unset($data_recs[$key]); // Unset the variable
}

--
Josip Dzolonga
http://josip.dotgeek.org

jdzolonga[at]gmail.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux