if ($cboxes = $dbi->query($vbox_result, 0)) {
foreach ($cboxes as $video) {
        $title = stripslashes ($video["title"]); 
        $wordWrappedTitle = wordwrap($title, 25, "\n");
        $full_title = stripslashes(str_replace("\"", "",$video["title"])); 
        $url =  $site_url.'video/'.$video["id"].'/'.seo_clean_url($full_title) .'/';


echo '
<div id="video-'.$video["id"].'" class="video">
<div class="thumb"> 
    <a class="clip-link" data-id="'.$video["id"].'" title="'.$full_title.'"  href="'.$url.'">
        <span class="clip">
            <img src="'.$video["thumb"].'" alt="'.$full_title.'" /> <span class="vertical-align"></span>
        </span>

        <span class="overlay"></span>
    </a>
     <span class="timer">'.sec2hms($video["duration"]).'</span>
    </div>  

This is the updated code. Will that work?

My [titles] are too long. I just really need to know where to add the word wrap. I think I do need more practice. I am trying to give this a shot.

有帮助吗?

解决方案

You just need to practice your program writing and syntax structure. I assume you want to wordwrap $title, so I'll just display it for now, what you wrote...

$title = stripslashes ($video["title"],.wordwrap , 25, '<br />',    true); 

Now since stripslashes takes in one argument, it wouldn't make sense to put in multiple arguments more than it's asking for; this is a huge indicator that this is what is causing the error messages. Just follow the pattern of what you did already above it for...

stripslashes($box_title)

Also, keep in mind that in php the '.' indicator means concatenate, so when you add that in front of certain key words there it means 'append to the string'. So having...

$title = stripslashes ($video["title"],.wordwrap , 25, '<br />',    true); 
                                       ^

Doesn't make sense because the thing before it is just a comma, not a string... so it cannot append to anything.

What you're trying to do is wordwrap $title after it is stripslashed right? One step at a time, best way to code...

First step, stripslash that sucker...

$title = stripslashes($video["title"]);

Note that I just inserted one argument, it just needs to strip slash it first.

Second step, wordwrap it, with the correct arguments of course. Wordwrap has many versions but the most simple is (text, maxwidth, separator) where separator is usually \n or \n

$wordWrappedTitle = wordwrap($title, 25, "\n");

I feel like another part of your code uses the $title variable for the $title on the videos but now your word wrapped result is inside of the $wordWrappedTitle variable, if you get an error about that or don't get what you expect try using that notion to figure out how to fix it (just replacing some variable names should do the trick).

EDIT:

Why would you have...

<h2 class="title"><a href="'.$url.'"  title="'.$full_title.'">'.$title.'</a></h2>
                                                                 ^^^^

When you want to use $wordWrappedTitle as your title that is now word wrapped. Here you're still using $title, but it has only been stripslashed. $wordWrappedTitle is the one that is word wrapped. So I recommend using it there instead of $title

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top