i´m trying to read a text file with telefone number inside this.
I need check if this phone number contains 9 or more digits or 16 digit or less.
my problem it´s that when i do this check, never entry in this condition and return error in my log… i´m edit code that it´s not mine and i don´t very well his logic.
i´m trying this:
case "fichero":
$log = "";
$fichero = $_FILES["lista_numeros"];
$fichero_valido = $this->validar_fichero();
if ($fichero_valido){
$lines = file($fichero["tmp_name"]);
$callers = array();
foreach ($lines as $line_num => $line){
$number = "";
$datos = $lines[$line_num];
if (strpos($datos,"rn") !== false && $line >= 9 && $datos <= 16){
$number = substr($datos, 0, strpos($datos, "rn"));
}
else{
$number = $datos;
}
// Se asigna el numero
if (is_numeric($number)){
//array_push($callers, array("numero" => $number, "id_lista" => $id, "id_grupo"=> $lista->ID_GRUPO));
array_push($callers, array("numero" => $number)); //, "id_lista" => $id, "id_grupo"=> $lista->ID_GRUPO));
}
else{
$log .= "Línea " .$line_num. ": '" .$number. "' no es numéricorn";
}
}
// Fichero de error
if ($log != ""){
$this->load->helper("file");
if (write_file($this->config->item("path_logs"). "log_" .$id. ".txt", $log)){
$msg_error_log = "Ha habido errores al insertar la lista de números [<a href='" .base_url(). "callers/log/" .$id. "'>Descargar log errores</a>]";
}
// else{
// $msg_error_log = "No se ha podido crear el fichero de errores";
// }
}
else{
if (!empty($callers)){
$lista = $this->Lista_model->obtener_lista($id);
$num_aniadidos = $this->insertarListaTelefonosCallerID($callers, $id, $lista->ID_GRUPO);
if ($num_aniadidos > 0){
$msg_info2 = "Se han insertado correctamente a la lista " .$num_aniadidos ." números";
}
else{
$msg_info2 = "No se encontraron teléfonos nuevos para añadir";
}
}
}
}
break;
always entry in this block:
else{
$log .= "Línea " .$line_num. ": '" .$number. "' no es numéricorn";
}
i don´t know that i´m doing wrong