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

    Hi,

    Array
    (
    [VALUE] => Test XML
    [TAG] => CUSTOMERCONTEXT
    [VALUE] => 1.0007
    [TAG] => XPCIVERSION

    ... etc
    )

    is not possible since, for example 'VALUE' can only appear once as a key in an array.

    Paul.

      yes you are right..i realized that the moment i posted the question.
      wht if now my array looks like this:
      array(
      [#document_1_QuantumViewResponse_0_Response_0_TransactionReference_0_CustomerContext_0] => Test XML
      [#document_1_QuantumViewResponse_0_Response_0_TransactionReference_1_XpciVersion_0] => 1.0007
      [#document_1_QuantumViewResponse_0_Response_1_ResponseStatusCode_0] => 1
      [#document_1_QuantumViewResponse_0_Response_2_ResponseStatusDescription_0] => Success
      [#document_1_QuantumViewResponse_1_QuantumViewEvents_0_SubscriberID_0] => smita_b
      )

      and i want it to look like this:
      [CustomerContext_0] => Test XML
      [XpciVersion_0] => 1.0007
      [ResponseStatusCode_0] => 1
      [ResponseStatusDescription_0] => Success
      [SubscriberID_0] => smita_b

      Can i do get result like this?

        In words,

        1. explode() the key on the '_'
        2. read off the last two entries
        3. join() the two entries from (2) back together again using '_'

        Paul.

          Write a Reply...