开发者

is it possible that for ever 5 items create a new <ul /><li /> in a new column?

I have a list of 50 items, and it gets kinda long. Is it possible to split that into 10 columns?

maybe in a table with 5 li's per td? and if it exceeds more than 10 td create a tr with another set of td?

well I'm sorry, this is my current script setup and its confusing me a little as to how to add the little condition.

if(isset($_POST['submit-script']))
{
    $path  = "./projects/scripts";
    $han开发者_开发知识库dle = new upload($_FILES['script']);
    if ($handle->uploaded)
    {
        $handle->file_overwrite = true;
        $handle->process($path);
        if ($handle->processed)
        {
            $handle->clean();
            $msg = "[ Your Script ".$handle->file_dst_name_body." has been uploaded ]";
            $file = $handle->file_dst_path.$handle->file_dst_name_body.'.'.$handle->file_dst_name_ext;
            $open = fopen($file, 'r+');
            $story = fread($open, filesize($file));
            $_ = NULL;
            if (preg_match_all('/\s{35}(.*)/m', $story, $_))
            {
                $counter = 0;
                $unique_characters = array_unique(array_map(create_function('$a', 'return ucfirst(strtolower(trim($a)));'), $_[1]));
                echo "<p>It looks like you have ".count($unique_characters)." characters in your script</p>\r\n";
                echo "\r\n";
                array_map(
                    create_function(
                        '$a',
                        'echo "<ul style=/"float:left;/">;
                        foreach($a as $item)
                        {
                            $counter++;
                            echo "<li>$item</li>";
                            if(is_int($counter/5) && count($unique_characters) >= $counter)
                            {
                                echo "</ul>\r\n";
                            }
                        '
                    ),
                $unique_characters);
            }

        }else{
            $msg = "<div class='error'>[ error : " . $handle->error .  ]</div>";
        }
    }
}

excerpt of $story:

EXT. DUNKIN' DONUTS - DAY 

               Police vehicles remain in the parking lot.  The determined
               female reporter from the courthouse steps, MELINDA FUENTES
               (32), interviews Comandante Chitt, who holds a napkin to his
               jaw, like he cut himself shaving. 

                                   MELINDA
                         < Comandante Chitt, how does it
                         feel to get shot in the face? >

                                   COMANDANTE CHITT
                         < Not too different than getting
                         shot in the arm or leg. >

                                   MELINDA
                         < Tell us what happened. >

                                   COMANDANTE CHITT
                         < I parked my car.
                             (indicates assault vehicle
                              in donut shop)
                         He aimed his weapon at my head.  I
                         fired seven shots. He stopped
                         aiming his weapon at my head. >

               Melinda waits for more, but Chitt turns and walks away into
               the roped-off crime scene. Melinda is confused for a second,
               then resumes smiling.

                                   MELINDA
                         < And there you have it... A man of
                         few words. >


Rather than putting all of these lists into td elements you could have a list;

<?php
$counter = 0;
$total_items = count($items);
print '<ul style="float:left;">';
foreach($items as $item)
{
    $counter++;
    print '<li>'.$item.'</li>';
    if( is_int($counter / 5) && $total_items >= $counter )
    {
        print '</ul>';
    }
}
print '</ul>'
?>

Basically every 5 $items this would close the current ul and open a new one.

Then all you'd need to do is float the ul elements to the left.


$data = range(1,58);
echo '<table><tr><td><ul>';
for ($i = 0; $i < count($data); $i++)
{
  if ($i && !($i % 5)) echo '</ul></td>';
  if ($i && !($i % 50)) echo '</tr><tr>';
  if ($i && !($i % 5)) echo '<td><ul>';
  echo '<li>'.$data[$i].'</li>';
}
echo '</ul></td></tr></table>';

...or something like that. The point is, it's possible.


Get each list of 10 in a <div> or any other block element, then set those divs style="float: left". They will take care of filling the page as wide as you want.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜