tüm dillerde i php zayıf im biliyorum ...
Ben oldukça basit ... bir csv dosyası alır ve onunla bazı şeyler yapan bir komut ... var.
the issue i am having: in_array('username', $headers) ... returns null... while... print_r ($headers); shows username being the first entry in the csv.
düşünceler? hatalar i yapmış olabilir?
TIA
Burada kod
/// 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;
}