PHP-API: Delete firewall filter rules, where comment started with "MYRULE" string

There are a lot of rules in “ip firewall filter”. Some of them are commented. Comments starts “MYRULE_” (for example MYRULE_user1, MYRULE_user2, and so on …)
I need to delete all ip firewall flter rules, where comment started with string “MYRULE_” .
I know how to do that in command line:

ip firewall filter remove [find [:pick $comment 0 6]="MYRULE"]

Now the same thing I need to do in PHP API. How to do it?

Acually I solved that, but I don’t like the solution so much …
My sollution:

  1. Read all rules from ip/firewall/filter to PHP array.
  2. Filter the array.
  3. Remove from ip/firewall/filter .id’s from the filtered array.

It works, but there are 3 steps. Better would be 1 step - just “Remove from ip/firewall/filter all rules, where comment contain MYRULES.” But I don’t know, how to do that.

Sadly, there’s no better way… not yet anyway.

In my API client, I have an util method to ease this, but it does those same steps under the hood. More specifically:

$util->setMenu('/ip firewall filter')->remove(function ($item) {
    return 0 === strpos($item('comment'), 'MYRULE');
});