Jump to content

Redeclare First_Sentence


EternalSorrow

Recommended Posts

I found this nice snippet of code to limit the output of my series descriptions to the first sentence, but I've run into a snag.

 

I want to be able to use the code in a "repeat region," but I receive this error message on the attempt:

 

Fatal error: Cannot redeclare first_sentence() (previously declared)

 

Is there any way to make this snippet of code repeat friendly?

 

Here's what I have so far:

<?php

$query = "SELECT * FROM series WHERE category = 'Animanga' ORDER BY id desc LIMIT 2 ";
$result = mysql_query($query);

while ($row = mysql_fetch_array($result))
{
extract($row);

function first_sentence($plot) {

    $pos = strpos($plot, '.');
    return substr($plot, 0, $pos+1);   
}

echo '<li><a href="counter.php?id='.$id.'">'.$series.'</a><br>
'.first_sentence($plot).'';

}      
?>

Link to comment
https://forums.phpfreaks.com/topic/174807-redeclare-first_sentence/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.