0

Notice at last line of code and I tried preg_split(":\",$fline) instead of split in but still I can see same notice

<?php
$file = fopen("employees.txt","r");
    $under_40=0;
    $salary_sum=0; 
    $emplist=[];
    $total_employees=0;
    echo "Names of all employees whose names end with son : <br/>";
    while(! feof($file))
      {
        $total_employees++;
        $fline=fgets($file);
list($name,$age,$dept,$salary)=split(':',$fline);
Aishwarya
  • 7
  • 1
  • 1
    I don't know if its a typo from adding your code here but there is no closing brace for the while loop – akaBase May 04 '20 at 10:02
  • 1
    Also to split the string use [explode](https://www.php.net/manual/en/function.explode.php) – akaBase May 04 '20 at 10:05
  • Are you 100% sure that all lines have at least 4 elements? Also, make sure that there are no blank lines in the end of the file. And as already pointed out, don't use `split()`. It was deprecated back in PHP 5.3 and removed in PHP 7. If you just want to split the string on colon, use: `explode(':', $fline)` instead – M. Eriksson May 04 '20 at 10:08

0 Answers0