Raymart Calinao AsthreA Raymart Calinao AsthreA - 1 year ago 129
PHP Question

Linebreak on text to create paragraphs php pdo

Is there a way to line break a certain sentences on the result text on pdo to break them in to two or more paragraphs each results..trying to achieve something like this pic

enter image description here

While my output was this one

enter image description here

I tried the answers in similar topic like this one Multiple paragraphs

using the code similar to

$content = $row['content'];
$breakpoint = round($content.length / 2); // half of the string length
$first = substr($content, 0, $breakpoint);
$second = sbustr($content, $breakpoint);

But it gives me a "undefined constant length" error Y.Y

my code block to load two results column names "details" and "more_details"

<?php if(isset($_GET['page'])):?>
<?php foreach($courses as $row):?>

<h1><?php echo $row['Fullname'];?></h1>
<?php echo $slug;?>

<?php echo $row['details'];?>
<?php echo $row['more_details'];?>

<?php endforeach;?>

found an answer thanks to forbs but i'm willing for another method if there would be another way


$content = $row['content'];
$breakpoint = round(strlen($content)/ 2); // half of the string length
$first = substr($content, 0, $breakpoint);
$second = substr($content, $breakpoint);

Answer Source

Well here's the answer for undefined constant length.
That's because content.length is Javascript, and you are in php.

$breakpoint = round(strlen($content)/ 2);

That should fix it, though that's gotta look very strange to be broken in the middle of a word.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download