Path: csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Ian Collins Newsgroups: comp.lang.php Subject: Re: parsing print_r() output with preg_match_all() Date: Thu, 14 Jan 2016 21:56:42 +1300 Lines: 45 Message-ID: References: <568d3dcf$0$23748$e4fe514c@news.xs4all.nl> <87r3huzevd.fsf@bsb.me.uk> <568d6f9c$0$23759$e4fe514c@news.xs4all.nl> <569363A3.6040108@arnowelzel.de> <5694313D.3060100@arnowelzel.de> <6929015.zlp62RpN2j@PointedEars.de> <569483AF.6010606@arnowelzel.de> <56956576.3040909@arnowelzel.de> <56956FF5.3050603@arnowelzel.de> <5695E316.9050809@arnowelzel.de> <56974F6B.1040705@arnowelzel.de> <20160114092044.04ce166e@geostat.dk> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net oL7kYwsjaqDL9TSBb8s3bgdIb3gvi3e8tZBDgSRObtBYDZImFo Cancel-Lock: sha1:omTsZvo4NOM0tV2AwhIlklS3ppM= User-Agent: Mozilla/5.0 (X11; SunOS i86pc; rv:17.0) Gecko/17.0 Thunderbird/17.0 In-Reply-To: <20160114092044.04ce166e@geostat.dk> Xref: csiph.com comp.lang.php:16269 Anders Wegge Keller wrote: > On Thu, 14 Jan 2016 08:34:03 +0100 > Arno Welzel wrote: > >> If one does not have any experience with XML, even this may not be clear >> to him: >> >> >> >> >> >> >> >> >> >> >> >> And is the key always a string or will numbers be treated different? In >> JSON it is possible to differentiate the data type as well, if needed: >> >> { >> "a": "apple", >> "b": "banana", >> "c": [ >> 1, >> 2, >> 3 >> ] >> } >> >> > > Didn't OP state "Human readable" as a requirement? The S/N ratio is much > better with JSON. For this simple structure, it is manageable, but when you > get a multi-megabyt XML file, it is time to bring out the special tools. Very true. The JSON representation will be shorter (with or without pretty printing) than the output of print_r() while conveying the same information. It also has the advantage of built in encoder and decoder - no messing with manual parsing. -- Ian Collins