Soporte & Consultoria

Soporte Remoto y Consultoria skype : ambiorixg12.
Nota no se brinda ningun tipo de consulta o soporte fuera del blog de forma gratuita

domingo, 8 de diciembre de 2024

get channel name function

$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