<?php
// Read the input string from a file
$inputString = file_get_contents('/home/voipessential/info_1.conf');
// Command line parameter
$searchValue = isset($argv[1]) ? $argv[1] : '';
// Explode the input string into an array based on the '-' delimiter
$lines = explode("\n", $inputString);
$dataArray = [];
// Iterate through each line and explode based on the '-' delimiter
foreach ($lines as $line) {
$values = explode('-', $line);
$dataArray[] = $values;
}
// Check if the search value is found in any array
foreach ($dataArray as $array) {
if (in_array($searchValue, $array)) {
// Set each value of the array as an Asterisk variable
foreach ($array as $key => $value) {
setAsteriskVariable($key, $value);
}
echo "Asterisk variables set for the array where the search value '$searchValue' is found.\n";
break; // Stop after the first occurrence
}
}
// Function to set Asterisk variable
function setAsteriskVariable($variableName, $variableValue) {
// Set Asterisk variable
echo "SET VARIABLE $variableName \"$variableValue\"\n";
}
?>
/home/voipessential/info_1.conf
No hay comentarios:
Publicar un comentario