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
https://forums.phpfreaks.com/topic/202756-substr/
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
https://forums.phpfreaks.com/topic/202756-substr/#findComment-1062663
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.