PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I am using this code to display a movie title, however I would like that I limit the number of characters that can be diplayed.
For example: "The Chronicles of Narnia: The Lion, the Witch and the Wardrobe" has about 50 characters. I would like to display only the first 10 characters, ie: "The Chroni" and then if possible add like 3 dots (...) that means the title is not all shown.
You need these two functions: strlen() and substr(). The first one gives you the length of a string, the second one - cuts a piece of a string and returns it. You simply check the title length and if it is longer than 10 characters, you cut the first 10 characters and append three dots to it.
Thanks for your help. It is working but only for one record. The query i have can get multiple records and this is only working on the first records then it displays;
Fatal error: Cannot redeclare shortTitle() (previously declared in C:\wamp\www\movie\comingsoon.php:41)
Thanks for your help. It is working but only for one record. The query i have can get multiple records and this is only working on the first records then it displays;
Fatal error: Cannot redeclare shortTitle() (previously declared in C:\wamp\www\movie\comingsoon.php:41)
Any idea why?
You can only define a function once. In a loop it tries to define it every loop iteration. Until you're more familiar with programming, I would just use:
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.