cakephp extract array
According to the documentation: "Tokens are composed of two groups. Expressions, are used to traverse the array data, while matchers are used to qualify elements.".
{n}[rating>-1] is considered one token.
{n} is the expression which filters the array keys, in this case the key must be numeric.
[rating>-1] is the matcher which filters the array elements, in this case the element must be an array that contains a key named rating and an associated value that is greater than -1.
Once you have the array element then you can get the rating.
$ratings = array(
'Rating' => array(
array(
'id' => 4,
'rating' => -1
),
array(
'id' => 14,
'rating' => 9.7
),
array(
'id' => 26,
'rating' => 9.55
)
)
);
print_r( Hash::extract($ratings, 'Rating.{n}[rating>-1].rating') );
Results in:
Array ( [0] => 9.7 [1] => 9.55 )
// input
$data = Array(
[0] => Array (
[Product] => Array (
[id] => 5
[product_number] => RT001C
))
[1] => Array (
[Product] => Array (
[id] => 7
[product_number] => RC001C
))
);
$data = Hash::extract($data, '{n}.Product');
// => output
$data = Array(
[0] => Array (
[id] => 5
[product_number] => RT001C
)
[1] => Array (
[id] => 7
[product_number] => RC001C
)
);
Also in PHP:
- check if string has a string php
- display all php erros
- fetch value from json link in php
- check the existing image in s3 laravel
- adjacent post sort order by post title
- chow to check which php version running wordpress
- ext dom php
- check typeof variable php
- centos 7 install php composer
- Allowed memory size of bytes exhausted (tried to allocate 4096 bytes) in phar:///usr/local/bin/composer/src/Composer/DependencyResolver/Solver.php
- check if array is duplicate and get the latest values php
- assoc key unique php
- errorLevel php no warnings
- doubles tennis random function php
- disable timestamp laravel
- Illuminate\Contracts\Container\BindingResolutionException Target class [HomeController] does not exist.
- daye in php
- display custom post type
- build laravel project
- check if the string match in php
- define header in php
- add +1 day in given date in php
- eloquent run seeder
- filesize in php