BrendanMullan Posted May 15, 2011 Share Posted May 15, 2011 Hi all just a bit like twitter i have a message system where when one recieves a mail i want there username to be like @user in blue but when sending a message the @user is in the message itself along with the actual message itsself, so i am trying to get the @ and everything after it so i can then change its color, can anyone help with this? Quote Link to comment https://forums.phpfreaks.com/topic/236466-string-get-text-after/ Share on other sites More sharing options...
BrendanMullan Posted May 15, 2011 Author Share Posted May 15, 2011 <?php $st = "@Brendan Hey Man"; $pizza = "@Brendan hey man"; $pieces = explode(" ", $pizza); echo "<font color='red'>".$pieces[0]; // piece1 ?> Got It Quote Link to comment https://forums.phpfreaks.com/topic/236466-string-get-text-after/#findComment-1215695 Share on other sites More sharing options...
BrendanMullan Posted May 15, 2011 Author Share Posted May 15, 2011 On second thoughts i have <?php if ($mto == $user){ echo"<font style='font-size: 14px;'>".$row2['message']; ?><br></font> <?php }else{ echo "<font color='red'>@".$mto."</font>"; echo " "; echo $row2['message']; } ?> So if i send a message to no one it will echo out normal but if i send it to someone else it will spilt the message and get the first word which is there user @user, but after @user i want to display the mesasage but putting $row2['message']; in will diaply the @user again because when sending a message you need to include @user at the start , how can i get rid of that after i have grabbed it from the string? Quote Link to comment https://forums.phpfreaks.com/topic/236466-string-get-text-after/#findComment-1215703 Share on other sites More sharing options...
wildteen88 Posted May 15, 2011 Share Posted May 15, 2011 Sounds like you need to remove the @user within $row2['message']; }else{ $msg = str_replace("@$mto", '', $row2['message']); echo "<font color='red'>@$mto</font> $msg"; } Quote Link to comment https://forums.phpfreaks.com/topic/236466-string-get-text-after/#findComment-1215704 Share on other sites More sharing options...
BrendanMullan Posted May 15, 2011 Author Share Posted May 15, 2011 Oh string replace i was strying substr, thanks for your help life saverr Quote Link to comment https://forums.phpfreaks.com/topic/236466-string-get-text-after/#findComment-1215705 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.