0

I have text file of array values for example

[26-11-2018 04:07:26]:     Array
(
    [0] => api.flights_published_search
    [1] => Array
        (
            [0] => Array
                (
                    [ticket_type] => single
                    [departure_airport_id] => THR
                    [arrival_airport_id] => MHD
                    [departure_date] => 21/12/2018
                    [direct_flight_only] => 0
                    [adults] => 1
                    [children] => 1
                    [child_ages] => Array
                        (
                            [1] => 11
                        )

                    [infants] => 1
                    [cabin_class] => Y
                )

        )

)

[26-11-2018 04:07:27]:     Array
(
    [status] => 1
    [pscId] => 0
    [localInventory] => Array
        (
            [cal] => 0
            [resp] => Array
                (
                )

        )

    [error] => Array
        (
            [status] => 
            [error] => Error Code: 3037, Error: No availability on chosen flights.
        )

)

I want to convert into as it is in array through php coding . so can anyone suggegst best way to convert this text to php array

M. Eriksson
  • 13,450
  • 4
  • 29
  • 40
ashutosh
  • 69
  • 8
  • Possible duplicate of [How create an array from the output of an array printed with print\_r?](https://stackoverflow.com/questions/7025909/how-create-an-array-from-the-output-of-an-array-printed-with-print-r) – M. Eriksson Nov 28 '18 at 15:06
  • Maybe this can help: http://www.php.net/manual/en/function.print-r.php#93529 – dWinder Nov 28 '18 at 15:07
  • ^ The accepted answer doesn't really work, but check [the answer by Adrian Cid Almaguer](https://stackoverflow.com/a/28687593/2453432) – M. Eriksson Nov 28 '18 at 15:07
  • Well, if you could access the PHP array, then you can simply serialize and unserialize it. – Ahmad Nov 28 '18 at 15:20
  • these array values are in log text file. so need to convert into array as it – ashutosh Nov 28 '18 at 15:38
  • The log file is generated by an external system. It logs all the requests and responses from an API system Unfortunately the way it is generated makes it difficult to convert as the structure is not a valid array. – ashutosh Nov 28 '18 at 16:00

0 Answers0