Jump to content

[SOLVED] is this a bad idea $e = substr($post['title'], 0, 40); if there is a chance...


onedumbcoder

Recommended Posts

is this a bad idea 

$e = substr($post['title'], 0, 40); 

if there is a chance that title might be less the 40chars long?

 

lets say the title is only 4 chars long, will it add 36 empty spaces? or am i fine using that.

 

Thank you and as always appreciate the help.

is this a bad idea 

$e = substr($post['title'], 0, 40); 

if there is a chance that title might be less the 40chars long?

 

lets say the title is only 4 chars long, will it add 36 empty spaces? or am i fine using that.

 

Thank you and as always appreciate the help.

 

<?php 
$sizeOfe = $strlen($e);
$e = substr($post['title'], 0, sizeOfe  < 40 ? sizeOfe : 40);
?>

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.