News Feed
Jobs Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Debuggable Blog:
XPath on PHP Arrays (Setextract)
September 26, 2008 @ 10:25:23

On the Debuggable blog there's an interesting post where Felix talks a bit about something I've seen requested quite a bit - a method for locating information in an array. His answer is an XPath-style query system to root out your custom information.

One of the requirements [of the original Set::extract method] was that the new method would need to be faster or at least as fast as the old implementation. My first attempts were big failures. Not only did the solutions I came up with contain tons of bugs. No, they were are also a lot slower the old extract function. A few benchmarks later and I discovered the biggest bottleneck in my implementation: Recursiveness.

He notes that no doing things recursively (not just in this situation, but ever) can help with a speed boost. In his example, a small change made all the differences and the XPath implementation in the CakePHP core makes grabbing information from any array simple.

While the implementation does not support full XPath (and probably won't in future), feel free to make suggestions on additional selectors or the idea in general.
0 comments voice your opinion now!
xpath array cakephp framework search recursion


blog comments powered by Disqus

Similar Posts

Tim Koschuetzki's Blog: How To Transform HTML To Textile Markup - The CakePHP TextileHelper Revisite

Akelos.org: Creating a weblog using the Akelos PHP Framework

Blog.szajbe.pl: Not so obvious behavior of $uses in CakePHP

Felix Geisendorfer's Blog: Model::save() now returns an array!

Felix Geisendörfer's Blog: Make printing easy, using a PrintController


Community Events











Don't see your event here?
Let us know!


facebook package introduction hack symfony2 application framework hhvm opinion dependency series overview install language composer release unittest component security podcast

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework