Path: csiph.com!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Ben Bacarisse Newsgroups: comp.lang.php Subject: Re: parsing print_r() output with preg_match_all() Date: Thu, 07 Jan 2016 20:24:14 +0000 Organization: A noiseless patient Spider Lines: 38 Message-ID: <87egdtt9xt.fsf@bsb.me.uk> References: <568d3dcf$0$23748$e4fe514c@news.xs4all.nl> <87r3huzevd.fsf@bsb.me.uk> <568d6f9c$0$23759$e4fe514c@news.xs4all.nl> <87fuyaza37.fsf@bsb.me.uk> <568e2b23$1$23766$e4fe514c@news.xs4all.nl> <87poxdwkl7.fsf@bsb.me.uk> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx02.eternal-september.org; posting-host="017616aa25f81ec581c44d76d61ba2f3"; logging-data="18345"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+d3+C4K/+E98zNmmHM8y2FA91Jd6377Ss=" Cancel-Lock: sha1:+kajCnF4yPs1rm1ifW0Mf2DeJvM= sha1:sGszT6LNV/Wopysas0zxBLzEbXQ= X-BSB-Auth: 1.7a28b79763a1c08eb300.20160107202414GMT.87egdtt9xt.fsf@bsb.me.uk Xref: csiph.com comp.lang.php:16156 Jerry Stuckle writes: > On 1/7/2016 9:05 AM, Ben Bacarisse wrote: >> Jerry Stuckle writes: >> >>> On 1/7/2016 4:03 AM, R.Wieser wrote: >>>> Jerry, >>>> >>>>> XML comes to mind. Human readable and made to >>>>> be easily parsed. >>>> >>>> Its also like shooting a cannon at a musquito. :-) >> >>> >>> Not really. It's exactly the type of job XML was designed for. And it >>> is easily created and read. >> >> These things are all relative. If, as I now suspect, a simple >> json_encode and json_decode call will do the job, XML is going to look >> over the top unless there's an xml_encode and xml_decode pair that can >> serialise standard PHP types (I'm not up-to-date with the latest PHP but >> I could not find such functions). > > There are any number of ways to implement XML in PHP. Encoding is as > simple as a loop and/or recursive function. The result is a document > compatible with the DOM and XML libraries. If there are no XML equivalents of json_(en|de)code then it's harder. How much harder is governed by more than just how simple it is in XML -- the other part of the calculation is how very simple it is with JSON. To use a naive measure (don't take this too literally) if it's 2 lines using XML, it's twice as hard as it using JSON. I don't know for sure because, whilst I've now checked how it works using JSON, I've not done it with XML but I'd bet it's more than a line or two each way. -- Ben.