I'm new to PHP and I have some problem with referencing a define constant to access array:
define('NAME_INDEX', 0);
...
if( $file ) {
while( ($line = fgets($file))!==false ) {
$array = explode(" , ", $line);
echo "<br>$array[NAME_INDEX]<br>";
}
}
The error that I received:
Notice: Undefined index: NAME_INDEX
It prints out the value that I want when I do echo $array[0] though. Might anyone know what went wrong?
$array['NAME_INDEX']won't work."<br>".$array[NAME_INDEX]."<br>"or"<br>{$array[NAME_INDEX]}<br>";