Use file() function to read a variable name, not a literal name.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • walterbyrd

    Use file() function to read a variable name, not a literal name.

    I know I can use the file() function to read a file into an array by
    providing a literal file name between single quotes:

    $lines = file('literal_f ile_name');

    But, what if I want file() to use a variable name?

    $variable_file_ name = "literal_file_n ame";
    $lines = file($variable_ file_name);

    Of course, that example won't work. But what will?

  • Miguel Cruz

    #2
    Re: Use file() function to read a variable name, not a literal name.

    "walterbyrd " <walterbyrd@ina me.comwrote:
    I know I can use the file() function to read a file into an array by
    providing a literal file name between single quotes:
    >
    $lines = file('literal_f ile_name');
    >
    But, what if I want file() to use a variable name?
    >
    $variable_file_ name = "literal_file_n ame";
    $lines = file($variable_ file_name);
    >
    Of course, that example won't work. But what will?
    Of course, that example will work. Why would you think otherwise?

    miguel
    --
    Photos from 40 countries on 5 continents: http://travel.u.nu
    Latest photos: Malaysia; Thailand; Singapore; Spain; Morocco
    Airports of the world: http://airport.u.nu

    Comment

    Working...