convert associative array to ordinary array

This is a discussion on convert associative array to ordinary array within the PHP General forums, part of the PHP Programming Forums category; Hi, i have an associative array and i want to use it as an ordinary array, is that possible? what ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 03-28-2008
It Maq
 
Posts: n/a
Default convert associative array to ordinary array

Hi,

i have an associative array and i want to use it as an
ordinary array, is that possible?

what i mean is instead of $arr['fruit'] i want to call
it by its position in the array $arr[3]

thanks


__________________________________________________ __________________________________
Never miss a thing. Make Yahoo your home page.
http://www.yahoo.com/r/hs

Reply With Quote
  #2 (permalink)  
Old 03-28-2008
Daniel Brown
 
Posts: n/a
Default Re: [PHP] convert associative array to ordinary array

On Fri, Mar 28, 2008 at 2:27 PM, It Maq <itmaqurfe@yahoo.com> wrote:
> Hi,
>
> i have an associative array and i want to use it as an
> ordinary array, is that possible?
>
> what i mean is instead of $arr['fruit'] i want to call
> it by its position in the array $arr[3]


Did you try?

--
</Daniel P. Brown>
Forensic Services, Senior Unix Engineer
1+ (570-) 362-0283
Reply With Quote
  #3 (permalink)  
Old 03-28-2008
M. Sokolewicz
 
Posts: n/a
Default Re: [PHP] convert associative array to ordinary array

Daniel Brown wrote:
> On Fri, Mar 28, 2008 at 2:27 PM, It Maq <itmaqurfe@yahoo.com> wrote:
>> Hi,
>>
>> i have an associative array and i want to use it as an
>> ordinary array, is that possible?
>>
>> what i mean is instead of $arr['fruit'] i want to call
>> it by its position in the array $arr[3]

>
> Did you try?
>

array_values() will throw out the keys and replace them with numeric
indices.

Anyway, in PHP there is no difference between an "associative array" or
an "ordinary array", they're both the same thing. Only one has integers
as keys while the other has strings...

- Tul
Reply With Quote
  #4 (permalink)  
Old 03-28-2008
Casey
 
Posts: n/a
Default Re: [PHP] convert associative array to ordinary array

On Fri, Mar 28, 2008 at 10:33 AM, Daniel Brown <parasane@gmail.com> wrote:
> On Fri, Mar 28, 2008 at 2:27 PM, It Maq <itmaqurfe@yahoo.com> wrote:
> > Hi,
> >
> > i have an associative array and i want to use it as an
> > ordinary array, is that possible?
> >
> > what i mean is instead of $arr['fruit'] i want to call
> > it by its position in the array $arr[3]

>
> Did you try?
>
> --
> </Daniel P. Brown>
> Forensic Services, Senior Unix Engineer
> 1+ (570-) 362-0283
>
>
>


$numbered_array = array_values($associative_array);

--
-Casey
Reply With Quote
  #5 (permalink)  
Old 03-28-2008
It Maq
 
Posts: n/a
Default Re: [PHP] convert associative array to ordinary array

thank you, it works!

--- Casey <heavyccasey@gmail.com> wrote:

> On Fri, Mar 28, 2008 at 10:33 AM, Daniel Brown
> <parasane@gmail.com> wrote:
> > On Fri, Mar 28, 2008 at 2:27 PM, It Maq

> <itmaqurfe@yahoo.com> wrote:
> > > Hi,
> > >
> > > i have an associative array and i want to use

> it as an
> > > ordinary array, is that possible?
> > >
> > > what i mean is instead of $arr['fruit'] i want

> to call
> > > it by its position in the array $arr[3]

> >
> > Did you try?
> >
> > --
> > </Daniel P. Brown>
> > Forensic Services, Senior Unix Engineer
> > 1+ (570-) 362-0283
> >
> >
> >

>
> $numbered_array = array_values($associative_array);
>
> --
> -Casey
>




__________________________________________________ __________________________________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i...Dypao8Wcj9tAcJ

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 07:25 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0