Longest Substring Without Repeating Characters - array functions

$string = 'hijklmnoabccdefgchhijklmno';
var_dump(checkString($string));

function checkString($string) {
  $longest = $substring = [];
  $end = 0;
  $string = str_split($string);
  
  for ($start = 0; $start < count($string); $start++) {

    $char = $string[$end];
        
    while (!in_array($char, $substring)) {
      $substring[] = $char;
      $end++;      
      
      if($end == count($string)) {
        break;
      }

      $char = $string[$end];
    }
      
    if (count($substring) > count($longest)) {
      $longest = $substring;
    }
    
    if (count($substring) == count($string) || $end == count($string)) {
      return $longest;
    }
    
    array_shift($substring);
  }
  
  return $longest;
}
    
index string functions