replace strings

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
racca
Forum Newbie
Posts: 2
Joined: Thu Feb 19, 2004 11:13 am

replace strings

Post by racca »

hi

i'm quite new to php and have a little question. how can i replace %string% trough array[string]??

greets RaCCa
malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

Post by malcolmboston »

i know bech100 is browsing these forums so im gonna be quick! :lol:

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
racca
Forum Newbie
Posts: 2
Joined: Thu Feb 19, 2004 11:13 am

Post 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

Code: Select all

str_replace("%*%",
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
Post Reply