Setting LINES as items in a ARRAY

Hello,
I have a file which ill set into a variable …
[php]$HELP = file_get_content(‘help.txt’)[/php]
I want to se each line of this archive in a Array, example:

How do i set this variable $HELP :

Hello Please Help Me

Into a Array:

$HELP[0] = Hello $HELP[1] = Please $HELP[2] = Help $HELP[3] = Me

(the file will not have 4 lines…)

Thanks :smiley:

PS:
I know i can use file()

but i really need to “convert” the lines of an variable into a array

Did it:
[php]$help = explode("
",$help);
echo $help[0];[/php]

Hi there,

Good to see you managed it, but just so you know - you can do that explode on one line:
[php]$help = explode("\n",$help);[/php]

(You can also use preg_split to allow support for any sort of new line character across various systems)

Thank you

Sponsor our Newsletter | Privacy Policy | Terms of Service