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 12:14:36 +1300 Lines: 56 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> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net frD7rMCeybUq4Z8Lwa+n3wSRIn64TagiM+JHWQsdrqVBVICtpZ Cancel-Lock: sha1:Fc9hM5BhMIe3YfyDs6vYULaPD4Q= User-Agent: Mozilla/5.0 (X11; SunOS i86pc; rv:17.0) Gecko/17.0 Thunderbird/17.0 In-Reply-To: Xref: csiph.com comp.lang.php:16257 Jerry Stuckle wrote: > On 1/13/2016 4:24 PM, Ian Collins wrote: >> >> The hypervisor OS I use uses JSON for all of its configuration and >> status output. It's clearly an easy format for both normal humans and >> machines to read. >> > > It is - IF you know what you're looking at. But give that to someone > who isn't familiar with JSON and expect them to understand it. Unlike > the output of print_r(), which is easy to understand, and XML, which can > be made to be quite easy to understand, if if the person doesn't > understand PHP, or XML. Given the first example on the print_r() manual page, do you think anyone who understands this: 'apple', 'b' => 'banana', 'c' => array ('x', 'y', 'z')); print_r ($a); ?> Array ( [a] => apple [b] => banana [c] => Array ( [0] => x [1] => y [2] => z ) ) would have trouble understanding this? 'apple', 'b' => 'banana', 'c' => array ('x', 'y', 'z')); echo json_encode($a,JSON_PRETTY_PRINT); ?> { "a": "apple", "b": "banana", "c": [ "x", "y", "z" ] } -- Ian Collins