Hello. How would you check the string for a particular word and just replace that word and not the string? I'm trying to do this so that when people just type in "google.com" or "facebook.com" or "us.gov", the site will just be linked instead of a blank text. When I tried, all the text in the string got linked and the link wasn't completed. When I viewed the page source, it was like
<a href="http://google.com<br>facebook.com<br>yahoo.com<br>us.gov<br>msn.com">google.com<br>facebook.com<br>yahoo.com<br>us.gov<br>msn.com</a>
The line breaks were suppose to be inserted when someone entered a new line. It should of outputted
<a href="http://google.com">google.com</a><br><a href="http://facebook.com">facebook.com</a><br><a href="http://yahoo.com">yahoo.com</a><br><a href="http://us.gov">us.gov</a><br><a href="http://msn.com">msn.com</a>
This is what I have
<?php $row_string = $row['string_message']; if(strpos($row_string,'.com') !== false) { ?> <a href='http://<?php echo $row_string; ?>' onmousedown='return false;' target='_new'><?php echo $row_string; ?></a> <?php } elseif(strpos($row_string,'.net') !== false) { ?> <a href='http://<?php echo $row_string; ?>' onmousedown='return false;' target='_new'><?php echo $row_string; ?></a> <?php } elseif(strpos($row_string,'.org') !== false) { ?> <a href='http://<?php echo $row_string; ?>' onmousedown='return false;' target='_new'><?php echo $row_string; ?></a> <?php } elseif(strpos($row_string,'.info') !== false) { ?> <a href='http://<?php echo $row_string; ?>' onmousedown='return false;' target='_new'><?php echo $row_string; ?></a> <?php } elseif(strpos($row_string,'.gov') !== false) { ?> <a href='http://<?php echo $row_string; ?>' onmousedown='return false;' target='_new'><?php echo $row_string; ?></a> <?php } elseif(strpos($row_string,'.biz') !== false) { ?> <a href='http://<?php echo $row_string; ?>' onmousedown='return false;' target='_new'><?php echo $row_string; ?></a> <?php } elseif(strpos($row_string,'.mx') !== false) { ?> <a href='http://<?php echo $row_string; ?>' onmousedown='return false;' target='_new'><?php echo $row_string; ?></a> <?php } elseif(strpos($row_string,'.lt') !== false) { ?> <a href='http://<?php echo $row_string; ?>' onmousedown='return false;' target='_new'><?php echo $row_string; ?></a> <?php } else { echo $row_string; } ?>