NYCPHP Meetup

NYPHP.org

[nycphp-talk] Change key values in array

Phillip Powell phillip.powell at adnet-sys.com
Thu May 20 13:39:28 EDT 2004


Rafi Sheikh wrote:

>Hi folks.  Is it possible to change the key value type in an array?  I have
>an array that has string key values, for my purposes I need it to have int
>index
>
>NOW LOOKS LIKE:
>array(6) { ["04-01"]=> int(0) ["04-02"]=> string(2) "32" ["04-03"]=> int(0)
>["04-04"]=> int(0) ["04-05"]=> int(0) ["04-06"]=> int(0) }
>
>I NEED IT TO LOOK LIKE:
>array(6) { [0]=> int(0) [1]=> string(2) "32" [2]=> int(0) [3]=> int(0) [4]=>
>int(0) [5]=> int(0) }
>
>  
>

 From first glance I would say just use array_values(), that creates the 
enumerative array you want from the original array with the values in 
the same order.

Phil

>REASON:
>I am getting date value from a DB, and than doing an array_merge with
>another template to ensure that any missing month for a category get a zero
>in the correct sequence.  Problem is that, the resulting array needs to have
>int index for the graphing utility to work.
>
>TIA
>
>
>This e-mail, including attachments, may include confidential and/or
>proprietary information, and may be used only by the person or entity to
>which it is addressed. If the reader of this e-mail is not the intended
>recipient or his or her authorized agent, the reader is hereby notified that
>any dissemination, distribution or copying of this e-mail is prohibited. If
>you have received this e-mail in error, please notify the sender by replying
>to this message and delete this e-mail immediately.
>_______________________________________________
>talk mailing list
>talk at lists.nyphp.org
>http://lists.nyphp.org/mailman/listinfo/talk
>
>  
>


-- 
---------------------------------------------------------------------------------
Phil Powell
Multimedia Programmer
BPX Technologies, Inc.
#: (703) 709-7218 x107 
Fax: (703) 709-7219

	




More information about the talk mailing list