Good morning everyone, I'm trying to get the length of a string from an array store in a variable so I can then use an "if". I use var_dump () where I can know the size of the string but I do not know how to compare that value, that data will be sent to a JSON and displayed in a DataTables (Jquery), could someone give me a light on this or some other alternative ? Thank you.
$sql = "SELECT q_num, time_start, from_userpart, ts_servicing FROM callcent_queuecalls WHERE q_num = '8010' AND ts_servicing = '00:00:00' ORDER BY time_start DESC";
$resultset = pg_query($conn, $sql) or die("database error:" . pg_errormessage($conn));
$data = array();
while ($rows = pg_fetch_array($resultset)) {
$array2 = $rows[2];
$meuarray = explode(' ', $array2);
foreach($meuarray as $valor) {
$imprime = strlen($valor);
echo $imprime."</br>";
}
}
SOLUTION
$array2 = $rows[2];
$intlen = strlen($array2);
if (($intlen === 8) || ($intlen === 9) || ($intlen === 11) || ($intlen === 12)) {
$meuarray = explode(" ", $array2);
foreach ($meuarray as $valor) {
$str = str_split($valor);
if (($str[0] === '1') || ($str[0] === '2') || ($str[0] === '7')) {
$exlui = array_shift($str);
}
$implode = implode("", $str);
echo "<pre>";
var_dump($implode);
}
}