steveh62 Posted December 15, 2008 Share Posted December 15, 2008 I have a php variable which pushes out some html etc etc. How can I break it so I can insert a function and then re-continue pushing the rest of the html? SEE WHERE i NEED THE FUNCTION IN THE CODE. and this is the function I need to insert <?php $keywords = explode(',', $keywords); foreach($keywords as $i){ $keywords = $i; echo '<a href="#" class="orange">'.$keywords.'</a> '; } ?> <?php $result_final =" <tr> <td valign='top'><div id='mainimage'> <a href='index.php?gid=$gid&image_max=$image_max&page=$page'><img src='site_images/back_btn.gif' border='0' title='back' alt='back'></a> <img src='".$images_dir."/".stripslashes($filename)."' border='0' alt='$title' title='$title'><br/> <table width='300' colspan='2'> <tr><td class='dropdown'>Keywords: <span class='orange'> --FUNCTION INSERT HERE-- </span></td></tr> </table><br> <table width='300' border='0' cellspacing='0' cellpadding='5'> <tr> <td COLSPAN='2' class='dropdown'><b>extra info</b></td> </tr> <tr> <td width='100'><img src='site_images/gallery_wrap_im.gif' width='100' height='83' alt='gallery wrap' title='gallery wrap'></td> <td valign='top' class='dropdown'><b>Gallery wrap.</b><br> The canvas is wrapped around the frame fully and the image appears on the sides of the frame as well as the front</td> </tr> <tr> <td><img src='site_images/face_wrap_im.gif' width='100' height='83' alt='face wrap' title='face wrap'></td> <td valign='top' class='dropdown'><b>Face wrap.</b><br> The image appears on the front of the canvas only leaving white edges</td> </tr> </table> </td> <td valign='top' align='left'> <div id='mainimagetitle'> title: $title<br/> <div id='detaildesc'> $desc <br/><br/> $output </div></div><br/></div> </td></div> </tr><script language='javascript' type='text/javascript'> CanvasFunction(); </script> "; } } // Final Output echo <<<__HTML_END <html> <head> <title></title> </head> <body> <table width='100%' border='0' align='left' style='width: 100%;'> $result_final </table> </body> </html> __HTML_END; ?> Link to comment https://forums.phpfreaks.com/topic/137034-solved-php-variables/ Share on other sites More sharing options...
Mchl Posted December 15, 2008 Share Posted December 15, 2008 You already have example in your code with stripslashes($filename) Link to comment https://forums.phpfreaks.com/topic/137034-solved-php-variables/#findComment-715687 Share on other sites More sharing options...
steveh62 Posted December 15, 2008 Author Share Posted December 15, 2008 I have tried to break out of the variable data using ".$variable." and it errors Link to comment https://forums.phpfreaks.com/topic/137034-solved-php-variables/#findComment-715690 Share on other sites More sharing options...
steveh62 Posted December 15, 2008 Author Share Posted December 15, 2008 if I tried the following it will error for some reason. the error...syntax error, unexpected '.' <?php resultend ="<tr><td class='dropdown'>Keywords: <span class='orange'>". $fetchkeywords = explode(',', $keywords); foreach($fetchkeywords as $i){ $showkeywords = $i; echo '<a href='#'>$showkeywords</a>'; } ."</span></td></tr>"; Link to comment https://forums.phpfreaks.com/topic/137034-solved-php-variables/#findComment-715693 Share on other sites More sharing options...
Mchl Posted December 15, 2008 Share Posted December 15, 2008 My... you really think PHP is magic, don't you? $result_final =" <tr> <td valign='top'><div id='mainimage'> <a href='index.php?gid=$gid&image_max=$image_max&page=$page'><img src='site_images/back_btn.gif' border='0' title='back' alt='back'></a> <img src='$images_dir/".stripslashes($filename)."' border='0' alt='$title' title='$title'><br/> <table width='300' colspan='2'> <tr><td class='dropdown'>Keywords: <span class='orange'>"; $keywords = explode(',', $keywords); foreach($keywords as $i){ $keywords = $i; $result_final .= "<a href='#' class='orange'>$keywords</a>"; } $result_final .= "</span></td></tr> </table><br> <table width='300' border='0' cellspacing='0' cellpadding='5'> <tr> <td COLSPAN='2' class='dropdown'><b>extra info</b></td> </tr> <tr> <td width='100'><img src='site_images/gallery_wrap_im.gif' width='100' height='83' alt='gallery wrap' title='gallery wrap'></td> <td valign='top' class='dropdown'><b>Gallery wrap.</b><br> The canvas is wrapped around the frame fully and the image appears on the sides of the frame as well as the front</td> </tr> <tr> <td><img src='site_images/face_wrap_im.gif' width='100' height='83' alt='face wrap' title='face wrap'></td> <td valign='top' class='dropdown'><b>Face wrap.</b><br> The image appears on the front of the canvas only leaving white edges</td> </tr> </table> </td> <td valign='top' align='left'> <div id='mainimagetitle'> title: $title<br/> <div id='detaildesc'> $desc <br/><br/> $output </div></div><br/></div> </td></div> </tr><script language='javascript' type='text/javascript'> CanvasFunction(); </script> "; Seriously. You should go and find some PHP book (and read it ) Link to comment https://forums.phpfreaks.com/topic/137034-solved-php-variables/#findComment-715699 Share on other sites More sharing options...
steveh62 Posted December 15, 2008 Author Share Posted December 15, 2008 quite frankly yes...its a progam language with structure and logic...so those that can remember thousands of syntax issues and amend them... then great. But until I master all of the 'geekery' I feel I have to ask and test...and yes I have books. Thanks for the solution anyhew Basically I thought you could only break out and in to code using . Link to comment https://forums.phpfreaks.com/topic/137034-solved-php-variables/#findComment-715706 Share on other sites More sharing options...
Mchl Posted December 15, 2008 Share Posted December 15, 2008 It might seem, that there 'thousands of syntax issues' in PHP, but in fact I doubt there is more than 100 strict rules, you have to follow to avoid syntax errors. It really is not that difficult. BTW: . (called concatenation operator) is used to join strings together, so "abc"."def" becomes "abcdef". Read more in manual Link to comment https://forums.phpfreaks.com/topic/137034-solved-php-variables/#findComment-715711 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.