Jump to content

Substr ?


jurass1c

Recommended Posts

I was wondering how to get "..." after the text i have cut using Substr. Here in an example of what i mean:

 

Say i wanted cut down something like a Movie name.

 

"Pulp Fiction" i use Substr to cut down the characters to only 7 so it would echo only "Pulp Fic" how would i go about adding "..." (3 dots) after Substr cuts off the name ?

 

so it would look like this "Pulp Fic..." - (notice the 3 dots after the name)

 

Its prob simple but i am yet to find a solution. any ideas ?

Link to comment
Share on other sites

Thanks man, i am still having a little trouble.  I did use this same method but what it does is echo all my results with an "..." after the substr even if the characters are under 7. so for example:

 

Say i have a 3 names in my database (Orange, Apple, Strawberry) under the field "Fruit", say  i want to limit the characters to "5" i use substr like above:

 

". substr($row['fruit'], 0, 5).'...' ."

 

It will work perfect for both "Orange and Strawberry" but when it comes to "Apple" (which is 5 characters) it will echo the "..." after it when it does not need to. Any idea's ?

 

Thanks.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

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.