Hyun Posted September 26, 2009 Share Posted September 26, 2009 Hello everyone! So, my friend coded this PHP code (SSI.php for SMF recent news function) for me: <?php $array = ssi_boardNews(2, 5, null, 2000, 'array'); foreach($array as $post) { echo ' <h4>', $post['subject'], '</h4> <h2>Posted by ', $post['poster']['link'], ' at ', date('G:i \o\n l, F j, Y', $post['timestamp']), '</h2> <p>', $post['body'], '</p> ', $post['comment_link']; } ?> I wanted to edit how the comment link looks so I edited it to this: <?php $array = ssi_boardNews(2, 5, null, 2000, 'array'); foreach($array as $post) { echo ' <h4>', $post['subject'], '</h4> <h2>Posted by ', $post['poster']['link'], ' at ', date('G:i \o\n l, F j, Y', $post['timestamp']), '</h2> <p>', $post['body'], '</p> <h2>', $post['comment_link'], '</h2>; } ?> But when I do this, I get an error. Warning: Unexpected character in input: ''' (ASCII=39) state=1 in /.../public_html/index.php on line 49 Parse error: syntax error, unexpected '<' in /.../public_html/index.php on line 49 How would I go about fixing this? I also want to add a horizontal rule after each post. Does anyone know how to add it? Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/175576-php-ending-code-help/ Share on other sites More sharing options...
smerny Posted September 26, 2009 Share Posted September 26, 2009 <h2>', $post['comment_link'], </h2>; edit that line to this: <h2>', $post['comment_link'], '</h2>'; Quote Link to comment https://forums.phpfreaks.com/topic/175576-php-ending-code-help/#findComment-925210 Share on other sites More sharing options...
Hyun Posted September 26, 2009 Author Share Posted September 26, 2009 Awesome! Thanks! It works now =] Quote Link to comment https://forums.phpfreaks.com/topic/175576-php-ending-code-help/#findComment-925220 Share on other sites More sharing options...
redarrow Posted September 26, 2009 Share Posted September 26, 2009 i really like this programming method of the array.. someone please explain it? $array = ssi_boardNews(2, 5, null, 2000, 'array'); <<< it a function to set internal values UNDERSTAND THAT. BUT foreach as $post now, but the $array variable not $array[] format? how can the function of ssi_boardNews let variable $array become a array Quote Link to comment https://forums.phpfreaks.com/topic/175576-php-ending-code-help/#findComment-925227 Share on other sites More sharing options...
Philip Posted September 26, 2009 Share Posted September 26, 2009 It returns an array. Quote Link to comment https://forums.phpfreaks.com/topic/175576-php-ending-code-help/#findComment-925237 Share on other sites More sharing options...
redarrow Posted September 26, 2009 Share Posted September 26, 2009 can you give a proper example with the function added as well so i can study this method cheers. Quote Link to comment https://forums.phpfreaks.com/topic/175576-php-ending-code-help/#findComment-925242 Share on other sites More sharing options...
Philip Posted September 26, 2009 Share Posted September 26, 2009 <?php function foo( ) { $a = array('foo','foobar', 'bar'); return $a; } $array = foo(); print_r($array); ?> Quote Link to comment https://forums.phpfreaks.com/topic/175576-php-ending-code-help/#findComment-925243 Share on other sites More sharing options...
Hyun Posted September 27, 2009 Author Share Posted September 27, 2009 I have one more question. How would you add a horizontal rule after each post? Would I add it on CSS? Quote Link to comment https://forums.phpfreaks.com/topic/175576-php-ending-code-help/#findComment-926127 Share on other sites More sharing options...
smerny Posted September 28, 2009 Share Posted September 28, 2009 could use a div and have each row of the loop be in separate divs and put bottom borders on them or something? kind of depends on what you want exactly Quote Link to comment https://forums.phpfreaks.com/topic/175576-php-ending-code-help/#findComment-926129 Share on other sites More sharing options...
Hyun Posted September 28, 2009 Author Share Posted September 28, 2009 could use a div and have each row of the loop be in separate divs and put bottom borders on them or something? kind of depends on what you want exactly I just want it to be as simple as possible 'cos I'm a php noob Quote Link to comment https://forums.phpfreaks.com/topic/175576-php-ending-code-help/#findComment-926130 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.