из всех языков, которые я знаю, я самый слабый в php ...
У меня есть скрипт ... который берет файл CSV и делает с ним что-то ... довольно простой.
проблема, с которой я столкнулся:
in_array ('username', $ headers) ... возвращает ноль ...
в то время как...
print_r ($ заголовки); показывает, что имя пользователя является первой записью в CSV.
мысли? ошибки, которые я мог совершить?
ТИА
код здесь
/// Turn the string into an array
$rows = explode("\n", $this->raw_data);
/// First row includes headers
$headers = $rows[0];
$headers = explode($this->delimiter, $headers);
/// Trim spaces from $headers
$headers = array_map('trim', $headers);
/// Check that there are no empty headers. This can happen if there are delimiters at the end of the file
foreach($headers as $header){
if(!empty($header)){
$headers2[] = $header;
}
}
$headers = $headers2;
if(! in_array('password', $headers)){
/// Add password column for generated passwords
$headers[] = 'password';
}
/// Add status column to the headers
$headers[] = 'status';
$this->headers = $headers;
/// Check that at least username, name and email are provided in the headers
if(!in_array('username', $headers) ||
!in_array('name', $headers) ||
!in_array('email', $headers)){
echo "error\n";
return false;
}