Re: remove keys from array
| From: | Afan Pasalic | Date: | Sun, 11 Jun 2006 21:45:58 +0000 |
| Subject: | Re: remove keys from array | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-237772@lists.php.net to get a copy of this message | ||
if you pull this array from mysql use this:
$query = mysql_query("SELECT * FROM table");
$result = mysql_fetch_array($query, MYSQL_ASSOC);
-afan
Rabin Vincent wrote:
On 6/11/06, Ahmed Abdel-Aliem <me2resh@gmail.com> 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