rastaman46 Posted May 20, 2012 Share Posted May 20, 2012 Hello got some problems with it if im change to "preg_replace its just stop working my php version is 5.3.10 Please help $loop = array("AVERAGETIME", "CURRENTLISTENERS", "PEAKLISTENERS", "MAXLISTENERS", "SERVERGENRE", "SERVERURL", "SERVERTITLE", "SONGTITLE", "SONGURL", "IRC", "ICQ", "AIM", "WEBHITS", "STREAMHITS", "LISTEN", "STREAMSTATUS", "BITRATE", "CONTENT"); $y=0; while($loop[$y]!=''){ $pageed = ereg_replace(".*<$loop[$y]>", "", $page); $scphp = strtolower($loop[$y]); $$scphp = ereg_replace("</$loop[$y]>.*", "", $pageed); // uncomment the next line to see all variables //echo'$'.$scphp.' = '.$$scphp.'<br>'; $y++; } Quote Link to comment Share on other sites More sharing options...
smoseley Posted May 20, 2012 Share Posted May 20, 2012 Perl Regex (preg) is different than POSIX Regex (ereg). Add "/' to the beginning and end of your patterns (and a "g" modifier if you want to replace all), and escape ("\") special characters in your patterns - <> / ( ) [ ] etc. That should get things working again, e.g.: $pageed = preg_replace("/.*\<{$loop[$y]}\>/g", "", $page); Quote Link to comment Share on other sites More sharing options...
.josh Posted May 20, 2012 Share Posted May 20, 2012 Php doesn't have a g modifier for pcre functions. preg_replace() by default performs global search and replace, and if you want to limit it there's an optional argument to pass to it Quote Link to comment Share on other sites More sharing options...
rastaman46 Posted May 20, 2012 Author Share Posted May 20, 2012 thanks for replay but if im use your exemple im get Warning: preg_replace() [function.preg-replace]: Unknown modifier 'g' in Quote Link to comment Share on other sites More sharing options...
smoseley Posted May 20, 2012 Share Posted May 20, 2012 Php doesn't have a g modifier for pcre functions. preg_replace() by default performs global search and replace, and if you want to limit it there's an optional argument to pass to it Oops! I stand corrected... Been working with too much JS lately, and completely forgot about that idiosyncrasy in php! thanks for replay but if im use your exemple im get Warning: preg_replace() [function.preg-replace]: Unknown modifier 'g' in Per josh's comment, if you remove the "g" it should work: $pageed = preg_replace("/.*\<{$loop[$y]}\>/", "", $page); Quote Link to comment Share on other sites More sharing options...
rastaman46 Posted May 20, 2012 Author Share Posted May 20, 2012 thanks again now got problem with this one :'( $$scphp = ereg_replace("</$loop[$y]>.*", "", $pageed); Quote Link to comment Share on other sites More sharing options...
.josh Posted May 20, 2012 Share Posted May 20, 2012 thanks again now got problem with this one :'( $$scphp = ereg_replace("</$loop[$y]>.*", "", $pageed); You apply the same principle you just learned to this line...use the gray matter between your ears bro... Quote Link to comment Share on other sites More sharing options...
rastaman46 Posted May 21, 2012 Author Share Posted May 21, 2012 Hello again and sorry for my noob questions but just cant get it working once im use your example its just stop working Quote Link to comment Share on other sites More sharing options...
.josh Posted May 21, 2012 Share Posted May 21, 2012 before... $pageed = ereg_replace(".*<$loop[$y]>", "", $page); after: $pageed = preg_replace("/.*\<{$loop[$y]}\>/", "", $page); before... $$scphp = ereg_replace("</$loop[$y]>.*", "", $pageed); after: ??? You have two lines of code that have the same problem: using a deprecated function. You have been told what you need to change, and someone even did the first line for you, so all you need to do is follow the instructions, or failing that, look at the changes in your first line and apply the same changes to the second line. Exactly what part of this are you having trouble with? Because at this point, this isn't even about coding, it's simple clerical skills...find and copy... Quote Link to comment Share on other sites More sharing options...
rastaman46 Posted May 21, 2012 Author Share Posted May 21, 2012 Thanks for replay after $$scphp = preg_replace("\<{$loop[$y]}\>/.*", "", $pageed); but get error "Delimiter must not be alphanumeric or backslash in" Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted May 21, 2012 Share Posted May 21, 2012 Here you go: CLICKY. Quote Link to comment Share on other sites More sharing options...
.josh Posted May 21, 2012 Share Posted May 21, 2012 Thanks for replay after $$scphp = preg_replace("\<{$loop[$y]}\>/.*", "", $pageed); but get error "Delimiter must not be alphanumeric or backslash in" Your first line of code has a / right after the opening ", and right before the closing ". How...HOW did you translate that to using a backslash as the opening delimiter, and putting the closing delimiter somewhere before your pattern ends? Man, you are making this WAY harder than it needs to be....I'm being serious here, not mean..if this is seriously too hard for you to understand, then you need to find another hobby besides coding, because this is NOT coding, this is copy and paste. If you cannot understand basic copy and paste, then you cannot even begin to code. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.