I have an array like this
Array
(
[0] => Array
(
[Unit] => Array
(
[Unit] => ST109347005
[SplitCnt] => 0
[UWin] =>
[Unit>Part] => MOLDTOOLREPAIR
[Unit>UK1] => MOLDSHELF1
[Unit>UK2] => 28149813MH001
[Unit>UK3] => MOLDTOOL
)
)
...
And would like to extract array of the serials stored in ‘Unit’ (ex: ST109347005) like this
$newarray = Set::extract($data,'/Unit[Unit>UK1=MOLDSHELF1][Unit>UK3=MOLDTOOL]/Unit');
Which doesn’t work because the > is a reserved character. I’m not sure what the syntax would be to allow this to work. I image it would be something like this (which doesn’t work)
$newarray = Set::extract($data,'/Unit[Unit\>UK1=MOLDSHELF1][Unit\>UK3=MOLDTOOL]/Unit');
Thanks
In then end it boils down to
Set::matches, which will receiveUnit>UK1=MOLDSHELF1as the condition, and evaluate it using a regular expression. Escape characters are not supported, somatchwill treat the>as the operator, and consequently it will fail.You’ll need to rename the keys, at least temporarily for extraction, however when you’re already iterating over all the entries you could easily compare the keys manually and skip the renaming and the extraction via
Set::extract. Ideally you should rename the keys permanently.