2

I am trying to add a "Read More" system on my site and right now I have the text stopping after 150 words, but I can't seem to get the link right at all.

This is what I have at the end of my shortening loop:

$string = substr($stringCut, 0, strrpos($stringCut, ' ')).'... <a href="posts.php?id='.$post['post_id'].'>Read More</a>';

When I look at my site the link points to this:

/posts.php?id=7%3ERead%20More%3C/a%3E...%3C/div%3E%3Cp%3EPosted%20on:%2030-09-14%2003:55:08in%20%3Ca%20href=

Its basically taking everything that comes after this (date and stuff) and putting it in my URL for some reason. If I just echo the post['post_id'] by itself I am getting the correct output. Any idea what I am doing wrong?

1
  • 2
    show the surrounding code Commented Oct 1, 2014 at 13:46

1 Answer 1

1

Try to change the link and add this missing closing double quotations on the markup:

$stringCut = 'aaaaaaaaaaaaaadddddddddddddddddadddddr ffff';
$post['post_id'] = 1;
$string = substr($stringCut, 0, strrpos($stringCut, ' ')).'... <a href="posts.php?id='.$post['post_id'].'">Read More</a>';
                                                                                                        ^^
echo $string;

Without closing quotes
With closing quotes

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.