Answer the question
In order to leave comments, you need to log in
Why different indexes in PHP array?
Good afternoon!
I’m slowing down something out of the blue)
Parse on php (5.5.14) a text file with a chat log, from the data I make an array of the form:
$users[$user_number]['start'] = $message_timestamp;
$users[$user_number]['status'] = "onchat";
$users[$user_number]['messagescount']="аааа";
function number_to_norm($number) {
$number_new = str_replace(array(" ", "-", "+", "‑", " "), "", $number);
$number = trim($number_new);
$number = strval($number);
return $number;
}
Answer the question
In order to leave comments, you need to log in
The problem is that for the first and second piece of code (adding array elements) php creates different array elements!
function number_to_norm($number) {
$number_new = str_replace(array(" ", "-", "+", "‑", " "), "", $number);
$number = trim($number_new); // Это лишнее, вы уже дважды удалили пробелы выше
$number = strval($number); // $number и так уже строка
return $number;
}
function number_to_norm($number) {
return str_replace(array(" ", "-", "+", "‑"), "", $number);
}
function number_to_norm ($number) {
return preg_replace('/\D/', '', $number);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question