dzhax Posted October 7, 2010 Share Posted October 7, 2010 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 More sharing options...
iwato Posted October 7, 2010 Share Posted October 7, 2010 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 More sharing options...
wirehopper Posted October 7, 2010 Share Posted October 7, 2010 As mentioned by iwato ... add slashes or other delimiters around the regexp.$seachLine = preg_replace("/<ul>/","<ul id=\"foo\">", $fullSource, 1); Link to comment Share on other sites More sharing options...
dzhax Posted October 7, 2010 Author Share Posted October 7, 2010 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 More sharing options...
Synook Posted October 8, 2010 Share Posted October 8, 2010 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 More sharing options...
dzhax Posted October 8, 2010 Author Share Posted October 8, 2010 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.