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() - question remains unanswered ... Date: Tue, 12 Jan 2016 11:25:39 +0000 Organization: A noiseless patient Spider Lines: 26 Message-ID: <87si23ujik.fsf@bsb.me.uk> References: <568d3dcf$0$23748$e4fe514c@news.xs4all.nl> <569362A6.2030707@arnowelzel.de> <56943207.1060207@arnowelzel.de> <5694d0c2$0$23771$e4fe514c@news.xs4all.nl> <5694daea$0$23814$e4fe514c@news.xs4all.nl> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx02.eternal-september.org; posting-host="017616aa25f81ec581c44d76d61ba2f3"; logging-data="22523"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+6gBn2UU3z+yCegjKBL8BSXk0Or0HV8io=" Cancel-Lock: sha1:5bMwfCO90UkoMjoN+sycC4s53Ds= sha1:f0DrCf3AwGQqHg6awplnma1deyA= X-BSB-Auth: 1.eee6e41b9fe81264f8c7.20160112112539GMT.87si23ujik.fsf@bsb.me.uk Xref: csiph.com comp.lang.php:16202 "R.Wieser" writes: > Although this thread has gotten quite a number of posts, I've not seen any > attempt to respond to my question : > > How do I get preg_match_all() to accept an "or" in the pattern (ok, this is > not that hard) *and* put the result in the "match" array in the order they > are found in (this one stumps me). I image that's because the problem was tied up with a task that most people thought should be abandoned and the specific example was rather fiddly. The question, as above, sounds odd because if I do this: $s = "one, two, two, three, one"; preg_match_all('/one|two/', $s, $m); var_dump($m); I get the matches in order. Maybe you should start with a simpler example like this to explain what's not happening as you'd like? There will be something about the way you use () and (?:) that needs to be adjusted, but it will be simpler to diagnose in as uncluttered an example as possible. -- Ben.