0

When i put a file inside the readline, i want that the pathinfo() show me its extension. But i want to add this code inside my function.

Let me show you my code :

function returnIcon($parts) {
    $extension = $parts['extension'];
    return $extension;
}

$pathinfo = pathinfo(readline('file name : '));
echo 'Extension: '.returnIcon($pathinfo);

so i want that my "pathinfo(readline( ..." work inside my function "returnIcon". I need to did it to use infinite loop on the readline when the input is false.

i am really stuck :/

Nigel Ren
  • 56,122
  • 11
  • 43
  • 55

1 Answers1

0

As simple way would be to put a loop on the readline() and continue while something has been typed in...

while ( $fileName = readline("file name:") )  {
    $pathinfo = pathinfo($fileName);
    echo 'Extension: '.returnIcon($pathinfo).PHP_EOL;
}
Nigel Ren
  • 56,122
  • 11
  • 43
  • 55