You are here: Re: [PHP] Simple array question, array delete « PHP « IT news, forums, messages
Re: [PHP] Simple array question, array delete

Posted by Josip Dzolonga on 04/06/05 16:07

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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация