In the line
$ API-> write ('= .id =', 3)
, you should not send the parameter "3", insted of that you have to first get the internal ".id" (also using the API).
A way to get the ".id", maybe not the optimal, is as follows:
//Get the DHCP-CLIENT details that match with interface wlan1
$arrResult = $API->comm ( '/ip/dhcp-client/print', array ("?interface" => 'wlan1') );
Play around with the previous line of code, e.g you could send no parameters to get all DHCP-clients or search by your custom criteria.
Note that the arrResult variable will contain all the DHCP-clients that matched with the query. You could use this array to build a previous screen where the user can select the desired interface, this is up to you.
//Get DHCP-CLIENT details of all (empty array).
$arrResult = $API->comm ( '/ip/dhcp-client/print', array () );
I tested the following code and it releases the dhcp-client set on wlan1:
<?php
require('routeros_api.class.php');
$API = new RouterosAPI();
$API->debug = true;
if ($API->connect('192.168.88.1', 'admin', '')) {
//Find DHCP clients on wlan1
$arrResult = $API->comm ( '/ip/dhcp-client/print', array ("?interface" => 'wlan1') );
var_dump($arrResult);//Just for debugging purposes
//Release all dhcp-clients
foreach ( $arrResult as $item ) {
$API->write ( '/ip/dhcp-client/release', false );
$API->write ( '=numbers=' . $item ['.id'] );
$API->read ( false );
}
}
else
{
$API->disconnect();
}
I hope this clarifies your doubts