I have an array like this:
Array(
[Rating] => Array(
[0] => Array(
[id] => 4
[rating] => -1
),
[1] => Array(
[id] => 14
[rating] => 9.7
),
[2] => Array(
[id] => 26
[rating] => 9.55
)
)
)
I need to extract all the ratings >= 0 from this array, and JUST the numbers. I was doing this fine with Set::extract('/Rating/rating[rating>-1]', $video)
But I then learned that this is deprecated and you are supposed to use the Hash class now. So I looked up the new syntax and wrote:
Hash::extract($video, 'Rating.{n}.rating[rating>-1]');
which gives me the correct result, but it gives an annoying warning: Warning (4096): Argument 1 passed to Hash::_matches() must be an array, string given, called in E:\www\lib\Cake\Utility\Hash.php on line 131 and defined [CORE\Cake\Utility\Hash.php, line 170]
The warning doesn't occur when I don't have the condition in there (the [rating>-1]
) but of course includes the -1's, which I don't want. What am I doing wrong here? Am I misusing this function somehow? Should I just use the deprecated Set class? Or should I just ignore the warning because it won't show up once I put this app into production mode?