Re: PHP Question
| From: | Kevin Kinsey | Date: | Thu, 28 Oct 2010 15:57:12 +0000 |
| Subject: | Re: PHP Question | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-309135@lists.php.net to get a copy of this message | ||
Paulo Work wrote:
Hello, Paulo!
I am building a website with basic CMS functionality. My problem is that in one of the pages I am using Easyslider to display small comments about the clients. These comments are divided in 3 per slide. ex:(<li> <p>comment 1/p> <p>comment 1/p> <p>comment 1/p> </li>) I am pulling the comments from the db and I would like to know if i can split that array in 3's (array_slice) perhaps? My goal is to within a foreach loop output 3 comments within a slide(wrapped in <li>), so first 3 would output: (<li> <p>comment 1/p> <p>comment 2/p> <p>comment 3/p> </li>) Then another 3I'm a hacker, so this is a HACK: <?php $data="(<li> <p>comment 1</p> <p>comment 2</p> <p>comment 3</p> </li>)"; $lines=explode("\n",$data); array_shift($lines); array_pop($lines); print_r($lines); ?> I'll leave it to the big boys to debate and devise more elegant solutions. Kevin Kinsey