I am a student, currently learning PHP and having a tough time getting the explode() function to work the way I want.
The following text file "vacations.txt" contains:
"54321", "Big Island Hawaii", "2999.00", "Best beaches big volcano"
"87654", "Cruise Caribbean", "3500.00", "Ocean view with balcony Cancun Jamaica etc."
"09876", "Rome and Madrid", "3999.00", "I see Italy I see Spain"
"32198", "Ski Tahoe", "1200.00", "Ski all day Gamble all night"
I have tried to put this into an array delimited by the comma. Using print_r(), I can see that it's all going into the first index of my array. Here's my code:
function displaySpecials() {
$prodString = include("vacation.txt");
$vacArray = explode(',', $prodString );
print_r($vacArray);
}
Here is the output:
"54321", "Big Island Hawaii", "2999.00", "Best beaches big volcano" "87654", "Cruise Caribbean", "3500.00", "Ocean view with balcony Cancun Jamaica etc." "09876", "Rome and Madrid", "3999.00", "I see Italy I see Spain" "32198", "Ski Tahoe", "1200.00", "Ski all day Gamble all night"Array ( [0] => 1 )
I have searched, and read everything I can find about explode(), but I cannot figure out why this is happening. My end goal is to output a multidimentional array in a table with 4 rows and 4 columns to display the 16 values in the text file.
All help is greatly appreciated. Thank you in advance!