Re: remove keys from array

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

 



This looks to me as printet result array from database:

$query = mysql_query("select * from table");
$result = mysql_fetch_array($query);
if you
print_r($result);
you'll get "doubled" values.
use
$result = mysql_fetch_array($query, MYSQL_ASSOC);
for "singles"

check: http://us2.php.net/manual/en/function.mysql-fetch-array.php

-afan



> Crap.. I remember seeing an example of something that yielded arrays like
> this and now I can't find it.
>
> It basically created an array (from a database I thought.. but can't find
> the example under mysql_fetch_assoc or mysql_fetch_array... thought it was
> in the standard PHP documentation (not the user comments).
>
> Anyway, it looked just like this.
>
> first array element key = "ID" and value = "2"
> second array element key = "CategoryName" and value = "asdasd"
>
> But you ended up with an array that merged an associative array and a
> regular indexed array.
>
> So you get, in addition to the above, a 0 = 2 and 1 = asdasd.
>
>
> Looks like he wants just the associative side of it.. not the indexed.
>
> -TG
>
> = = = Original message = = =
>
> On Sun, June 11, 2006 6:57 am, Ahmed Abdel-Aliem wrote:
>> hi all
>> 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 ) )
>>
>> can anyone help me with that plz ?
>
>
> I don't even understand the question...
>
> Where did this array come from?
>
>
> ___________________________________________________________
> Sent by ePrompter, the premier email notification software.
> Free download at http://www.ePrompter.com.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

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