waffe
asked on
loading text file with fopen - single and double quotes need to be encoded?
Hi I have simple text file that I am loading with fopen() but when I do the single and double quotes are change to odd looking characters. I recognize the problem as URL encoding but nothing seems to work. What am I missing?
ASKER
Here you go:
****PHP code that loads the text file and converts each line into an element in an array and then displays a random line.*************
<?php
$file_handle = fopen("http://dev.my.com/mod/my_theme/views/default/my1_pages/slogans.txt", "r") or die ("Unable to open file!");
$counter = 0;
while (!feof($file_handle)) {
$line_of_text = fgets($file_handle);
$sloganArray[$counter] = $line_of_text;
$counter++;
}
$randomNum = rand(1, 63);
print $sloganArray[$randomNum];
fclose($file_handle);
?>
********the text I am opening***********
Sometimes I feel like a nut, sometimes I feel like my1
Id walk a mile for my1
my1 99 99/100 % pure
With a name like my1&it has to be good
Is it live, or is it my1?
my1&so easy a caveman can do it.
I want my1
Nothing outlasts my1. It keeps going and going and going&
Like a good neighbor, my1 is there.
Maybe shes born with it, maybe its my1
Youve come a long way, my1
The my1 of champions
my1 good to the last video
my1&its GRE-A-A-A-T!!
Wouldnt you like to be my1, too?
I wish I were on my1, then everyone would be in love with me.
Nothing beats a great pair of my1s
The Greatest my1 on Earth
They my1 when you cook em.
I am stuck on my1, and my1s stuck on me!
my1 dont leave home without it
Its not your fathers my1
ASKER
Its actually the apostrophe that is loading wired and the above lines of text show the problem. ^
ASKER
ok got it - it was not an apostrophe, or at least one on my keyboard. so I selected and do a search & replace with a normal apostrophe and all is well.
Thanks,
waffe
Thanks,
waffe
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
ah - that works too :)
can i see the text file and ur code. if possible.