Set::extract()ã®å°æ´è½ã使ãæ¹ case.1
ãã¾ã«ã¯è»½ããã¿ããããããããé£è¼ãããã
<?php $users = array( array( 'User' => array( 'id' => 1, ), ), array( 'User' => array( 'id' => 2, ), ), array( 'User' => array( 'id' => 3, ), ), );
ã®ã¨ãã
<?php $ids = Set::extract('/User/id', $users);
ã¨ããã¨
<?php $ids = array( 1, 2, 3, );
ã¨ãªãã¾ããããã¯çµæ§æ¨æºçãªä½¿ãæ¹ã§ããã
<?php $data = array( 'PreviousUser' => array( 'id' => 1, ), 'User' => array( 'id' => 2, ), 'NextUser' => array( 'id' => 3, ), );
ããã§ã
<?php array( 'PreviousUser' => 1, 'User' => 2, 'NextUser' => 3, );
ã¨ãããµãã«åãåºãããã¨ãã¾ãã
<?php $ids = Set::extract('{.+?}.id', $data);
ããã§åãåºãã¡ããã¾ããXPathã®ããæ¹ã¯ã¡ãã£ã¨æãã¤ãã¾ããã§ããã誰ãæãã¦ï¼
ãªãã{}ã®éã«ã¯æ£è¦è¡¨ç¾ãæå®ã§ãã¾ããæè»ã§ããï¼