Re: remove keys from array

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

 



On 6/11/06, Ahmed Abdel-Aliem <me2resh@xxxxxxxxx> wrote:
when i have array in the form of :
Array ( [0] => 2 [ID] => 2 [1] => asdasd [CategoryName] => asdasd ) )
how can i make it in the form of :
Array ( [ID] => 2 [CategoryName] => asdasd ) )

To remove a single element you can use unset: unset($arr[0]);. To
remove all the elements with integer indices you could just loop, check,
and unset those ones.

What do you need to do this for? Your examples looks like arrays got
from mysql_fetch_array. If this is so, using mysql_fetch_assoc() instead
of that will get you only the associative array.

Rabin

--
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