preg_replace for values in array

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
smilesmita
Forum Commoner
Posts: 30
Joined: Thu May 24, 2007 1:52 pm

preg_replace for values in array

Post by smilesmita »

hi there,
i have an array which looks like this:
Array
(
[0_0_0_0_VALUE] => Test XML
[0_0_0_0_TAG] => CUSTOMERCONTEXT
[0_0_0_1_VALUE] => 1.0007
[0_0_0_1_TAG] => XPCIVERSION
[0_0_0_TAG] => TRANSACTIONREFERENCE
[0_0_1_VALUE] => 1
[0_0_1_TAG] => RESPONSESTATUSCODE
[0_0_2_VALUE] => Success
[0_0_2_TAG] => RESPONSESTATUSDESCRIPTION
[0_0_TAG] => RESPONSE
[0_1_0_VALUE] => smita_b
[0_1_0_TAG] => SUBSCRIBERID
[0_1_1_0_VALUE] => Alternate Billing
[0_1_1_0_TAG] => NAME
[0_1_1_1_VALUE] => 82C0E7922B3BA32B
[0_1_1_1_TAG] => NUMBER
[0_1_1_2_0_VALUE] => A
[0_1_1_2_0_TAG] => CODE
[0_1_1_2_1_VALUE] => Active
[0_1_1_2_1_TAG] => DESCRIPTION
[0_1_1_2_TAG] => SUBSCRIPTIONSTATUS
[0_1_1_3_0_VALUE] => 070801_151740001
)

I wanted to have some preg_replace pattern which would get me an even output like this :( i would like to just keep the words "tag " and "value" in the array key field instead of the numbers"
Array
(
[VALUE] => Test XML
[TAG] => CUSTOMERCONTEXT
[VALUE] => 1.0007
[TAG] => XPCIVERSION
......so on and so forth...

Please help.

-smita
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

I don't think it's possible to have an array with more than one key having the same name.
Post Reply