Page 1 of 1
replace strings
Posted: Thu Feb 19, 2004 11:13 am
by racca
hi
i'm quite new to php and have a little question. how can i replace %string% trough array[string]??
greets RaCCa
Posted: Thu Feb 19, 2004 11:16 am
by malcolmboston
i know bech100 is browsing these forums so im gonna be quick!
string replace
eg
Code: Select all
$motd = "/etc/motd";
$file = fopen("$motd", "r");
$content = fread($file, filesize($motd));
$content2 = str_replace("\n", "<br>", $content);
fclose($file);
print $content2;
hope that helps
Posted: Thu Feb 19, 2004 4:42 pm
by racca
thanks, i tried it with the str_replace function but i don't know how to do use it, so that i can replace %number% with $nameofthearray[number].
i think i have to begin with
but how can i put the number between the '%' into the array?
could you explain to me how to use the function in that case?
thanks very much, racca