cakephp-2.0 > Set :: extract()
Set
A
AbstractTransport
AclBehavior
AclComponent
AclInterface
AclNode
AclShell
Aco
AcoAction
ActionsAuthorize
ApcEngine
ApiShell
App
AppController
AppController
AppHelper
AppHelper
AppModel
AppModel
AppShell
Aro
AuthComponent
B
BadRequestException
BakeShell
BakeTask
BaseAuthenticate
BaseAuthorize
BasicAuthenticate
BasicAuthentication
BehaviorCollection
C
Cache
CacheEngine
CacheException
CacheHelper
CacheSession
CakeEmail
CakeErrorController
CakeException
CakeLog
CakeLogException
CakeLogInterface
CakePlugin
CakeRequest
CakeResponse
CakeRoute
CakeSchema
CakeSession
CakeSessionException
CakeSessionHandlerInterface
CakeSocket
ClassRegistry
CommandListShell
Component
ComponentCollection
ConfigReaderInterface
Configure
ConfigureException
ConnectionManager
ConsoleErrorHandler
ConsoleException
ConsoleInput
ConsoleInputArgument
ConsoleInputOption
ConsoleInputSubcommand
ConsoleOptionParser
ConsoleOutput
ConsoleShell
ContainableBehavior
Controller
ControllerAuthorize
ControllerTask
CookieComponent
CrudAuthorize
D
DatabaseSession
DataSource
DbAcl
DbAclSchema
DbConfigTask
DboSource
Debugger
DebugTransport
DigestAuthenticate
DigestAuthentication
Dispatcher
E
EmailComponent
ErrorHandler
ExceptionRenderer
ExtractTask
F
File
FileEngine
FileLog
FixtureTask
Folder
ForbiddenException
FormAuthenticate
FormHelper
H
Helper
HelperCollection
HelpFormatter
HtmlHelper
HttpException
HttpResponse
HttpSocket
I
I18n
I18nModel
i18nSchema
I18nShell
Inflector
IniReader
InternalErrorException
J
JqueryEngineHelper
JsBaseEngineHelper
JsHelper
L
L10n
M
MailTransport
MediaView
MemcacheEngine
MethodNotAllowedException
MissingActionException
MissingBehaviorException
MissingComponentException
MissingConnectionException
MissingControllerException
MissingDatabaseException
MissingDatasourceConfigException
MissingDatasourceException
MissingHelperException
MissingLayoutException
MissingModelException
MissingPluginException
MissingShellException
MissingShellMethodException
MissingTableException
MissingTaskException
MissingTestLoaderException
MissingViewException
Model
ModelBehavior
ModelTask
MootoolsEngineHelper
Multibyte
Mysql
N
NotFoundException
NumberHelper
O
Object
ObjectCollection
P
PagesController
PagesController
PaginatorComponent
PaginatorHelper
Permission
PhpReader
PluginShortRoute
PluginTask
Postgres
PrivateActionException
ProjectTask
PrototypeEngineHelper
R
RedirectRoute
RequestHandlerComponent
Router
RouterException
RssHelper
S
Sanitize
Scaffold
ScaffoldView
SchemaShell
Security
SecurityComponent
SessionComponent
SessionHelper
SessionsSchema
Set
Shell
ShellDispatcher
SmtpTransport
SocketException
Sqlite
Sqlserver
String
T
TaskCollection
TemplateTask
TestsuiteShell
TestTask
TextHelper
ThemeView
TimeHelper
TranslateBehavior
TreeBehavior
U
UnauthorizedException
UpgradeShell
V
Validation
View
ViewTask
W
WincacheEngine
X
XcacheEngine
Xml
XmlException
extract
line:350 at
/lib/Cake/Utility/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)
public extract
($path, $data = null, $options = array())
Parameters
Parameter | Type | Comment | Default |
---|---|---|---|
$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
arrayComment
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
@link http://book.cakephp.org/2.0/en/core-utility-libraries/set.html#Set::extract
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
@link http://book.cakephp.org/2.0/en/core-utility-libraries/set.html#Set::extract