Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP inserting variable into a link href and name
    primarykey
    data
    text
    <p>This is the code I am working with:</p> <pre><code>&lt;?php $rss = new DOMDocument(); $rss-&gt;load('http://hugeriver.wordpress.com/feed/'); $feed = array(); foreach ($rss-&gt;getElementsByTagName('item') as $node) { $item = array ( 'title' =&gt; $node-&gt;getElementsByTagName('title')-&gt;item(0)-&gt;nodeValue, 'desc' =&gt; $node-&gt;getElementsByTagName('encoded')-&gt;item(0)-&gt;nodeValue, 'link' =&gt; $node-&gt;getElementsByTagName('link')-&gt;item(0)-&gt;nodeValue, 'date' =&gt; $node-&gt;getElementsByTagName('pubDate')-&gt;item(0)-&gt;nodeValue, ); array_push($feed, $item); } $limit = count($feed); for($x=0;$x&lt;$limit;$x++) { $title = str_replace(' &amp; ', ' &amp;amp; ', $feed[$x]['title']); $link = $feed[$x]['link']; $description = $feed[$x]['desc']; $date = date('l F d, Y', strtotime($feed[$x]['date'])); echo '&lt;h2&gt;&lt;a name="test"&gt;'.$title.'&lt;/a&gt;&lt;span class="line"&gt;&lt;/span&gt;&lt;/h2&gt;'; echo '&lt;small&gt;&lt;em&gt;Posted on '.$date.'&lt;/em&gt;&lt;/small&gt;&lt;/p&gt;'; echo '&lt;p&gt;'.$description.'&lt;/p&gt;'; } ?&gt; </code></pre> <p>I am stuck specifically with this line. I am trying to make it so the title is both the name of the ancor and the link (so when clicked it scrolls to the top). This is what I tried that doesn't work. Can anyone please show me what is wrong with my syntax? </p> <pre><code>echo '&lt;h2&gt;&lt;a name="'.$title'" href="#'.$title'"&gt;'.$title.'&lt;/a&gt;&lt;span class="line"&gt;&lt;/span&gt;&lt;/h2&gt;'; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload