/    Sign up×
Community /Pin to ProfileBookmark

Limit an echo

I wonder how can I limit an echo:

Custmers write description of their products and after I echo them:

<? echo $row[‘Descripcion’]; ?>

But sometimes descrption is too long and I would like to show only the first 350 characters of the description, because tables look very bad when description is too long.

How can I do that?

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@PittimannDec 04.2003 — Hi!

Something like that would help:
[code=php]
<?
if (strlen($row['Descripcion'])<=350){
echo $row['Descripcion'];
}
else{
echo substr($row['Descripcion'], 0, 350);
}
?>
[/code]

Cheers - Pit
Copy linkTweet thisAlerts:
@pyroDec 04.2003 — You should probably also enter something at the end, so people know that the description has been altered...
Copy linkTweet thisAlerts:
@PittimannDec 04.2003 — Hi!

Absolutely correct, pyro!! I should have added something like that in the "else" part - I simply forgot it. Thanks!

Cheers - Pit
Copy linkTweet thisAlerts:
@pyroDec 04.2003 — No problem... ?
×

Success!

Help @Perfidus spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.30,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...