SitePoint Sponsor |
|
User Tag List
Results 1 to 3 of 3
Thread: Check (if . exists) and Remove?
-
Apr 22, 2009, 14:12 #1
- Join Date
- Jul 2003
- Location
- Toronto, Ontario
- Posts
- 234
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Check (if . exists) and Remove?
Hey guys,
I was just trying to figure out how...
Check if a variable contains a . in it. Then remove everything after that dot.
Any help, or a point in the right direction would be appreciated.
Thanks,
Mario$ Available For Hire
Need a website designed or coded? Then feel free to contact me!
PSP Backgrounds - PSPBG.net || Photoshop Brushes - PSBrushes.net
-
Apr 22, 2009, 14:20 #2
- Join Date
- Jul 2006
- Location
- Augusta, Georgia, United States
- Posts
- 4,194
- Mentioned
- 17 Post(s)
- Tagged
- 5 Thread(s)
PHP Code:$str = 'xewdwe dfew .fwefwef we f we f we .f wef';
$pos = strpos($str,'.');
if($pos!==false) {
$str = substr($str,0,$pos);
}
echo '<p>',$str,'</p>';
-
Apr 22, 2009, 15:47 #3
oddz' code works well. You could also use the following which should also do the trick.
PHP Code:$str = 'xewdwe dfew .fwefwef we f we f we .f wef';
$str = strtok($str, '.');
echo '<p>', $str, '</p>';
Bookmarks