[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 174
  • Last Modified:

Strings

Hello!

I'm looking for the function to get the first x_number of characters from a string...

For example:

The string "This string of text is a little bit too long." should be displayed as:
"This string of text is..."
0
Julian Matz
Asked:
Julian Matz
  • 2
1 Solution
 
b0lsc0ttIT ManagerCommented:
julianmatz,

You can use substr.  An example would be substr(str, 0, x) where str is the string and x is an integer for the number of character.

str = "abcdef"
smallstr = substr(str, 0, 3)

smallstr would equal abc.

b0lsc0tt
0
 
Julian MatzJoint ChairpersonAuthor Commented:
Hi b0lsc0tt,

Thank you for the quick answer! Exactly what I was looking for but had trouble finding it in the manual...
http://php.net/manual/en/function.substr.php

-Julian.
0
 
b0lsc0ttIT ManagerCommented:
julianmatz,

Glad I could help.  Thanks for the fun question, grade and points.
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now