Jump to content
xisto Community
Sign in to follow this  
iGuest

1st 5 Chars 1st 5 chars from the word

Recommended Posts

Can someone tell me, how to getfirst 5 characters from the some word i have i my database (mysql)example:$word = VerylongLonglognword_or_sentence;$short_w= veryl...;

Share this post


Link to post
Share on other sites

Can someone tell me, how to get

first 5 characters from the some word i have i my database (mysql)

example:

$word = VerylongLonglognword_or_sentence;

$short_w= veryl...;

58012[/snapback]


I'm going to use the variables that you've used. Say your $word contains the very long word. Now:

 

$short_w = substr ( $word, 0, 5 );

This should extract the first 5 characters from your $word and store it in $short_w. This is assuming you are using PHP with MySQL. If you want a little more explanatin - the substr function extracts a substring from your string based on the parameters provided to it. General form is: susbstr ( LargeString, StartPosition, LengthOfSubString ) - this extracts a string of length LengthOfSubString starting at position StartPosition from your original string LargeString.

 

Hope this helps. :angry:

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.