justinomaha Posted May 18, 2009 Share Posted May 18, 2009 I'm very new to programming so I apologize in advance if this is a stupid question! I'm need the results of a for each loop saved as a variable. Here is what I'm trying: $sitemap = "foreach( $finalurl as $key => $value){ echo '<url><loc>http://www.$mainsiteurl.com/$finalurl[$key]</loc><changefreq>daily</changefreq><priority>0.9</priority></url>'; }"; Does anyone know how to do this? Thanks for anyone's help! Quote Link to comment https://forums.phpfreaks.com/topic/158619-beginnner-needs-help-with-for-each/ Share on other sites More sharing options...
wildteen88 Posted May 18, 2009 Share Posted May 18, 2009 Correct syntax: $sitemap = ''; foreach( $finalurl as $key => $value){ $sitemap .= '<url><loc>http://www.$mainsiteurl.com/'.$value.'</loc><changefreq>daily</changefreq><priority>0.9</priority></url>'; } echo $sitemap; Quote Link to comment https://forums.phpfreaks.com/topic/158619-beginnner-needs-help-with-for-each/#findComment-836569 Share on other sites More sharing options...
justinomaha Posted May 18, 2009 Author Share Posted May 18, 2009 Thank you very much... that worked great! Quote Link to comment https://forums.phpfreaks.com/topic/158619-beginnner-needs-help-with-for-each/#findComment-836620 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.