Jump to content

preg_replace


dzhax

Recommended Posts

all i need to do is search a string for the FIRST <ul> and add an id tag to it.and either replace the current string or make another one.i tried

$seachLine = preg_replace("<ul>","<ul id=\"foo\">", $fullSource, 1);

Link to comment
Share on other sites

i tried
$seachLine = preg_replace("<ul>","<ul id=\"foo\">", $fullSource, 1);

Try here before you try again. All regular expressions must be properly delimited, else they are not recognized as regexp.Roddy
Link to comment
Share on other sites

wow i feel stupid... the one thing i didn't do...i should have known too with my recent use of grep...ill give that a go and see what happens.

Link to comment
Share on other sites

Since you don't need an actual regular expression for this replace, it would be more appropriate to just use str_replace().

Link to comment
Share on other sites

i actually dont need it to only do the first <ul> anymore.so i can make a function that would loop through the string and find all the <a href="./images/WHAT EVER . EXTENSION"> and replace it with <a href="./img/WHAT EVER . EXTENSION">???for some reason this would never work for me properly. can i see an example of how you would preform the above operation?

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...