Not exactly wordpress question, more of a php but –
The syntax for echo is quit simple :
You start with a quotation mark, and close with a quotation mark.
But since INSIDE the HTML we also need quotation marks , we separate them by using the single '
for PHP and the double "
for HTML.
every time you have a php function, command, or variable, you should close the single quotation mark, place a DOT .
and also put a dot .
after, and re-open the single quotation mark if needed. close all with semicolumn
So it would look like this :
echo ' <mytag class=" ' . $phpvariable . ' " title = " continueHtml " ' ;
in your case :
echo '<p class=\"readmore\"><a href="https://wordpress.stackexchange.com/questions/42808/. $permalist[$j] ." title="your title" >Read More »</a></p>';
OR
echo "<h2><a href=\"$permalist[$j]\" >$titlelist[$j]</a></h2>";
echo '<h2><a href=""https://wordpress.stackexchange.com/questions/42808/. $permalist[$j] .""/>' . $titlelist[$j] . '</a></h2>';
I am not familiar with permalist[$j] – does it being produced by you in any manner ? or did you mean permalink ? or are you using some kind of plugin that produces it ?
Edit
Using your code above, just change the syntax, and use the_title_attribute()
:
<?php
echo '<p class="readmore"><a href=""https://wordpress.stackexchange.com/questions/42808/. $permalist[$j] ."" title="' . the_title_attribute( array( 'echo' => 0 ) ) . '">Read More »</a></p>.;
?>