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 ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
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 |
|
|||
|
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 |
|
|||
|
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 |
|
|||
|
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 |
|
|||
|
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 |