PHP! How to insert if function? Or better using another solution?

by 3 replies
4
PHP Code:
<a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php echo thman_get_limited_string($post->post_title,13); ?></a>
Because there isn't enough space for the whole title the title has to be cut but this code creates a second line if the last displayed word* is too long.

Example 1
Whole title: 12345 123456 12345678* 12345678 1234567890
(2 Lines)

12345 123456
12345678*...

Example 2
hole title: 123 123456 123456 12345678 1234567890
(1 Line)

123 123456 123456...
Question:

How can I change the code to insert a <br /> if I get Example 2? And if I get Example 1 then a <br /> shouldn't be inserted.

PHP Code:
Solution
Solusion 1
Whole title: 12345 123456 12345678* 12345678 1234567890
(2 Lines)

12345 123456
12345678*...

Solution 2
hole title: 123 123456 123456 12345678 1234567890
(1 Line)

123 123456 123456...
<br />
#programming #function #insert #php #solution
  • This sounds like a job for my good friends, if, then else, they work really well together and hardly ever get into trouble,

    PHP If...Else Statements

    have a look at this I think it should put you on the right path to discover my good friends, say hello when you find them, they hang out just about everywhere these days,
    • [1] reply
    • What function I need to filter out if it reads out 2 lines or just 1 line? Does a trick exist to get that?
      • [1] reply

Next Topics on Trending Feed

  • 4

    PHP Code: <a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php echo thman_get_limited_string($post->post_title,13); ?></a> Because there isn't enough space for the whole title the title has to be cut but this code creates a second line if the last displayed word* is too long. Example 1