Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Trouble distinguishing email address in variable
Old 10-25-2007, 02:36 AM Trouble distinguishing email address in variable
Experienced Talker

Posts: 40
Trades: 0
I'm interested in checking a string for a @ and, if it has one, do something like

HTML Code:
if(strstr($msg,'@'))
{   
   <a href="<? echo"$msg"; ?>">
}
I'm not sure how to implement this though. Can it be entered into the html or does it need to go with the php code at the top. And if it goes at the top, how do I enter it in the html?

TIA for the assistance.
Prometheus is online now
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 10-25-2007, 06:10 AM Re: Trouble distinguishing email address in variable
Foundationflash's Avatar
Ultra Talker

Posts: 410
Name: Harry Burt
Location: Colchester, Essex, England
Trades: 0
Note from PHP.net:

Note: If you only want to determine if a particular needle occurs within haystack, use the faster and less memory intensive function strpos() instead

If you want echo something in the middle of the HTML just put <?php
?> in where you want the echo to be - PHP can be put anywhere, it's only by convention at the top.

This would leave you with something like:

PHP Code:
<?php
if(strpos($msg,'@') !== false)
{
echo 
$msg;
}
?>
Just put that wherever you want $msg to be echoed.

Hope that helps!
__________________
Foundation Flash tutorials :
Please login or register to view this content. Registration is FREE


New Dreamed Up Web Design:
Please login or register to view this content. Registration is FREE
Foundationflash is offline
Reply With Quote
View Public Profile Visit Foundationflash's homepage!
 
Old 10-25-2007, 12:13 PM Re: Trouble distinguishing email address in variable
Experienced Talker

Posts: 40
Trades: 0
That's good to know, thanks again for the help. My problem now is if it finds an '@' how do I make it insert <a href="mailto:......"> instead of just printing it?
Prometheus is online now
Reply With Quote
View Public Profile
 
Old 10-25-2007, 12:18 PM Re: Trouble distinguishing email address in variable
Foundationflash's Avatar
Ultra Talker

Posts: 410
Name: Harry Burt
Location: Colchester, Essex, England
Trades: 0
You want
PHP Code:
if(strpos($msg,'@') !== false)
{
echo 
"<a href=\"mailto:".$msg."\">Something</a>";

__________________
Foundation Flash tutorials :
Please login or register to view this content. Registration is FREE


New Dreamed Up Web Design:
Please login or register to view this content. Registration is FREE
Foundationflash is offline
Reply With Quote
View Public Profile Visit Foundationflash's homepage!
 
Old 10-28-2007, 04:02 AM Re: Trouble distinguishing email address in variable
Experienced Talker

Posts: 40
Trades: 0
You rock.
Prometheus is online now
Reply With Quote
View Public Profile
 
Reply     « Reply to Trouble distinguishing email address in variable
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.14739 seconds with 12 queries