NameSilo

Need code quick! 25 NP$! URGENT

SpaceshipSpaceship
Watch

user-7256

VIP Member
Impact
111
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
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
if(substr($var, -1, 1) == '-' OR substr($var, 0, 1) == '-') {
echo "Error";
}
 
0
•••
wouldn't you have to find the total chars in the word first, then look back 1?
 
0
•••
0
•••
Yah, you got it. Sorry.
 
0
•••
Le Wolf has got it :) Works. 25 NP$ sent.
 
0
•••
CatchedCatched

We're social

Escrow.com
Spaceship
Rexus Domain
CryptoExchange.com
Domain Recover
CatchDoms
DomDB
NameFit
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back