$channel = "SIP/8001-3455ac;";
function get_channel($channel, $device) {
// Ensure $device is treated as a string for consistency in comparison
if (strpos($channel, (string)$device) !== false) {
// Use a more robust way to extract the channel before the dash
return explode("-", $channel)[0];
}
return null; // Return null if the device is not found
}
$device = 8001;
$channelResult = get_channel($channel, $device);
if ($channelResult) {
echo "Channel: " . $channelResult;
} else {
echo "Device not found in the channel.";
}
No hay comentarios:
Publicar un comentario