Path: csiph.com!news.mixmin.net!weretis.net!feeder1.news.weretis.net!news.solani.org!.POSTED!not-for-mail From: Thomas 'PointedEars' Lahn Newsgroups: comp.lang.php Subject: Re: parsing print_r() output with preg_match_all() Date: Thu, 07 Jan 2016 18:23:39 +0100 Organization: PointedEars Software (PES) Lines: 29 Message-ID: <2284570.LMhpeJnbiT@PointedEars.de> 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> <874meqyvo5.fsf@bsb.me.uk> <87y4c2umsm.fsf@ahungry.com> <87twmqumn9.fsf@ahungry.com> <87k2nly7x3.fsf@bsb.me.uk> <8027862.ZV2veRrZ9M@PointedEars.de> <871t9txzil.fsf@bsb.me.uk> <2593390.uV5jh8T4Yt@PointedEars.de> Reply-To: Thomas 'PointedEars' Lahn Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7Bit X-Trace: solani.org 1452187420 1813 eJwNysERACEIA8CWFEgYyxGO9F+Ct++Fc7MzCAYEfbxpbuRRWfXxnCxwsq8cgcVtMuX80Xz1AxnnEQU= (7 Jan 2016 17:23:40 GMT) X-Complaints-To: abuse@news.solani.org NNTP-Posting-Date: Thu, 7 Jan 2016 17:23:40 +0000 (UTC) User-Agent: KNode/4.14.2 X-User-ID: eJwFwYEBwCAIA7CXBrVQzwGV/09YQoTFyRWMxeH4x9q4nbdAndSmY/q4FVxPgXutXYapyjJZR+O1Hj+14wdKMhVU Cancel-Lock: sha1:CTheyDgxGx3RZCQz41cvyapppGI= X-NNTP-Posting-Host: eJwNysERwDAIA7CVaLCBjpP44v1HaPUWs55So1ig6T6uDvLAIPDeLU+s1QqPkzt5z580TYXwARoJETw= Xref: csiph.com comp.lang.php:16150 Thomas 'PointedEars' Lahn wrote: > $ php -r 'var_dump(json_decode(json_encode([1 => 42, "foo" => "bar"]), > true));' > array(2) { > [1] => > int(42) > 'foo' => > string(3) "bar" > } > > $ php -r 'var_dump(array_keys(json_decode(json_encode([1 => 2, "foo" => > "bar"]), true, 512, JSON_OBJECT_AS_ARRAY)));' JFTR: The 512 and JSON_OBJECT_AS_ARRAY arguments are from testing if JSON_OBJECT_AS_ARRAY makes a difference; they can be safely omitted. > array(2) { > [0] => > int(1) > [1] => > string(3) "foo" > } -- PointedEars Zend Certified PHP Engineer | Twitter: @PointedEars2 Please do not cc me. / Bitte keine Kopien per E-Mail.