soma56 Posted June 18, 2010 Share Posted June 18, 2010 I created this script to grab a random value from a page. I'm trying my best to condense the code as much as possible. The problem is, although everything works correctly as far as retrieving a random value I also get a "<br>" tag right before the value that comes back - this of-course messes up everything... <?PHP $page = file('http://www.mysite.php'); $rand_value = array_rand($page, 2); echo $page[$rand_value[0]] . "\n"; ?> I know how to change it to plain text however, I'm hoping someone here has a short and effective way to remove "<br>" from my array. Quote Link to comment https://forums.phpfreaks.com/topic/205219-need-good-advice-on-str_replace/ Share on other sites More sharing options...
Alex Posted June 18, 2010 Share Posted June 18, 2010 You said the solution, so what's the problem? echo str_replace('<br />', '', $page[$rand_value[0]]) . "\n"; Quote Link to comment https://forums.phpfreaks.com/topic/205219-need-good-advice-on-str_replace/#findComment-1074192 Share on other sites More sharing options...
soma56 Posted June 18, 2010 Author Share Posted June 18, 2010 Thankyou AlexWD! You know, I had a feeling it was something as ridiculously simple as that. Ever read into something way too much? Quote Link to comment https://forums.phpfreaks.com/topic/205219-need-good-advice-on-str_replace/#findComment-1074199 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.