Hi guys,

I was wondering if anyone can help. I need to count the number of lines of text in an array (they are separated as bullet points at the moment) and after a certain amount of lines, the array will carry on from a new column.

Really struggling at the moment and would love some help.


Can you give an example of how your array looks ?

Yup, this is the part - pulling in data:

if (array_key_exists('DynamoDesc', $Car) && !is_null($Car['DynamoDesc'])){
                                $desc = array();
                                foreach ($Car['DynamoDesc'] as $DynamoDesc) {
                                    if (!preg_match("|^<strong>customContactInformation</strong>|", $DynamoDesc)) {
                                        $x = true;
                                        $counter = 0;

                                        while (strpos($DynamoDesc, '<li>', $counter)) { 
                                            $position = strpos($DynamoDesc, '<li>', $counter);
                                            $endCount = $position - $counter;
                                            if ($counter > 0) 
                                                $string = '<li>';
                                                $string = '';
                                            $string .= substr($DynamoDesc, $counter, $endCount);
                                            $desc[] = $string;
                                            $counter = $position + 4;
                                        $string = '<li>' . substr($DynamoDesc, $counter);
                                        $desc[] = $string;


I don't know if I understood your question but you can try this :

<p style='width: 200px; padding: 0; line-height: 20px;'>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque nibh metus, sodales sed auctor et, euismod et mi. Maecenas elit eros, bibendum vel aliquet nec, aliquam et dui. Vivamus vel risus tellus, ut dignissim sem. In pellentesque augue eu augue egestas auctor. Maecenas volutpat viverra est, at malesuada leo euismod in.

<script type="text/javascript">
        var element = document.getElementsByTagName('p')[0];
        var nb_lines = element.offsetHeight / 20; // 20 => line-height
commented: Not Javascript! +0

Hi Akmozo,
We are in PHP here. Not JavaScript.