cakephp-1.3 > Set :: extract()
A AclBase AclBehavior AclComponent AclNode AclShell Aco AcoAction AjaxHelper ApcEngine ApiShell App AppController AppController AppHelper AppHelper AppModel AppModel Aro AuthComponent B BakeShell BakeTask BehaviorCollection C Cache CacheEngine CacheHelper CakeErrorController CakeLog CakeRoute CakeSchema CakeSession CakeSocket ClassRegistry Component Configure ConnectionManager ConsoleShell ContainableBehavior Controller ControllerTask CookieComponent D DataSource DbAcl DbAclSchema DbConfigTask DboMssql DboMysql DboMysqlBase DboMysqli DboOracle DboPostgres DboSource DboSqlite Debugger Dispatcher E EmailComponent ErrorHandler ErrorHandler ExtractTask F File FileEngine FileLog FixtureTask Folder FormHelper H Helper HtmlHelper HttpSocket I I18n I18nModel i18nSchema I18nShell Inflector IniAcl J JavascriptHelper JqueryEngineHelper JsBaseEngineHelper JsHelper L L10n M MagicDb MagicFileResource MediaView MemcacheEngine Model ModelBehavior ModelTask MootoolsEngineHelper Multibyte N NumberHelper O Object Overloadable Overloadable Overloadable2 Overloadable2 P PagesController PagesController PaginatorHelper Permission PluginShortRoute PluginTask ProjectTask PrototypeEngineHelper R RequestHandlerComponent Router RssHelper S Sanitize Scaffold ScaffoldView SchemaShell Security SecurityComponent SessionComponent SessionHelper SessionsSchema Set Shell ShellDispatcher String T TemplateTask TestSuiteShell TestTask TextHelper ThemeView TimeHelper TranslateBehavior TreeBehavior V Validation View ViewTask X XcacheEngine Xml XmlElement XmlHelper XmlManager XmlNode XmlTextNode

extract

line:373 at /cake/libs/set.php
Implements partial support for XPath 2.0. If $path is an array or $data is empty it the call is delegated to Set::classicExtract.

Method

(array) extract ($path, $data = null, $options = array())

Parameters

ParameterTypeCommentDefault
$path string required An absolute XPath 2.0 path
$data array optional An array of data to extract from null
$options array optional Currently only supports 'flatten' which can be disabled for higher XPath-ness array()

Return

array

Comment

Implements partial support for XPath 2.0. If $path is an array or $data is empty it the call
is delegated to Set::classicExtract.

#### Currently implemented selectors:

- /User/id (similar to the classic {n}.User.id)
- /User[2]/name (selects the name of the second User)
- /User[id>2] (selects all Users with an id > 2)
- /User[id>2][<5] (selects all Users with an id > 2 but < 5)
- /Post/Comment[author_name=john]/../name (Selects the name of all Posts that have at least one Comment written by john)
- /Posts[name] (Selects all Posts that have a 'name' key)
- /Comment/.[1] (Selects the contents of the first comment)
- /Comment/.[:last] (Selects the last comment)
- /Comment/.[:first] (Selects the first comment)
- /Comment[text=/cakephp/i] (Selects the all comments that have a text matching the regex /cakephp/i)
- /Comment/@* (Selects the all key names of all comments)

#### Other limitations:

- Only absolute paths starting with a single '/' are supported right now

**Warning**: Even so it has plenty of unit tests the XPath support has not gone through a lot of
real-world testing. Please report Bugs as you find them. Suggestions for additional features to
implement are also very welcome!

@param string $path An absolute XPath 2.0 path
@param array $data An array of data to extract from
@param array $options Currently only supports 'flatten' which can be disabled for higher XPath-ness
@return array An array of matched items
@access public
@static