Scripting and [] commands in PEAR2_Net_RouterOS

Using PEAR2_Net_RouterOS-1.0.0b6

The following works fine the in the Mikrotik Terminal. But I cant get it to work via the API. How would I do the following:

:foreach user in=[/ip firewall address-list find find address=10.2.2.2] do={

   /ip firewall address-list disable $user
}

Or

ip firewall address-list disable [/ip firewall address-list find address=10.2.2.2]

Easiest would be:

$util = new RouterOS\Util($client);
$util->setMenu('/ip firewall address-list')->disable(RouterOS\Query::where('address', '10.2.2.2'));

Although there is a bug with Util and queries with multiple matches that’s already fixed in the upcoming version… Until that version is released, if you have more than one match, you could use:

$ids = array();
$util->setMenu('/ip firewall address-list');
foreach ($util->getAll(array('.proplist' => '.id'), RouterOS\Query::where('address', '10.2.2.2')) as $item) {
    $ids[] = $item('.id');
}
$util->disable(implode(',', $ids));

Thank you, so much!