[advanced search]
 

Go Back   NamePros.com > Discussion > Web Design & Development > Programming

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.


Closed Thread
 
LinkBack Thread Tools
Old 11-05-2005, 08:43 AM   #1 (permalink)
DNOA Member
 
mholt's Avatar
 
Join Date: May 2004
Location: Utah
Posts: 5,041
18.01 NP$ (Donate)

mholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant future

Autism Marrow Donor Program 9/11/01 :: Never Forget Multiple Sclerosis Adoption Alzheimer's Lou Gehrig's Disease (ALS)
Caution Need code quick! 25 NP$! **URGENT**

hey,

I need a quick PHP code that does this:

Finds whether a hyphen is the FIRST character in a string OR LAST character.

E.g. It displays an error for this:

-test

And this:

test-

But not this:

te-st

or....

tes-t

Etc. Just first and last character. 25 NP$ to the person who can write up this PHP code real quick, I can't figure it out for some reason.

Thanks,
-Matt
__________________
codeboards

A high-quality community of programmers -- Join today and post! We want new members!
mholt is offline  
Old 11-05-2005, 06:21 PM   #2 (permalink)
NamePros Member
 
Join Date: Jul 2005
Posts: 100
45.15 NP$ (Donate)

Le Wolf is on a distinguished roadLe Wolf is on a distinguished road


if(substr($var, -1, 1) == '-' OR substr($var, 0, 1) == '-') {
echo "Error";
}
__________________
My host is better than yours
Le Wolf is offline  
Old 11-05-2005, 06:31 PM   #3 (permalink)
NamePros Regular
 
Palyriot's Avatar
 
Join Date: Jul 2004
Location: Seattle, Wa
Posts: 596
76.25 NP$ (Donate)

Palyriot is a jewel in the roughPalyriot is a jewel in the roughPalyriot is a jewel in the rough


wouldn't you have to find the total chars in the word first, then look back 1?
Palyriot is offline  
Old 11-06-2005, 12:06 AM   #4 (permalink)
NamePros Regular
 
gamex's Avatar
 
Join Date: Feb 2004
Location: Student @ UConn
Posts: 408
73.95 NP$ (Donate)

gamex has a spectacular aura aboutgamex has a spectacular aura about


Look at http://us2.php.net/substr
__________________
Joe
CarrotCash.com
gamex is offline  
Old 11-06-2005, 12:24 AM   #5 (permalink)
NamePros Regular
 
Palyriot's Avatar
 
Join Date: Jul 2004
Location: Seattle, Wa
Posts: 596
76.25 NP$ (Donate)

Palyriot is a jewel in the roughPalyriot is a jewel in the roughPalyriot is a jewel in the rough


Yah, you got it. Sorry.
Palyriot is offline  
Old 11-06-2005, 03:47 PM   #6 (permalink)
DNOA Member
 
mholt's Avatar
 
Join Date: May 2004
Location: Utah
Posts: 5,041
18.01 NP$ (Donate)

mholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant future

Autism Marrow Donor Program 9/11/01 :: Never Forget Multiple Sclerosis Adoption Alzheimer's Lou Gehrig's Disease (ALS)
Le Wolf has got it Works. 25 NP$ sent.
__________________
codeboards

A high-quality community of programmers -- Join today and post! We want new members!
mholt is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
120 NP$ Logo Contest (Quick Contest!) ClutchCut Design Contests 13 10-20-2005 02:23 PM
Quick! - Small flash header animation needed - NP$ 145 Virgil Design Contests 4 07-21-2005 02:23 PM

Site Sponsors
Advertise your business at NamePros

All times are GMT -7. The time now is 02:49 PM.


Powered by: vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0
Template-Modifications by TMS
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85