You are here: Re: cut off a string? « PHP Programming Language « IT news, forums, messages
Re: cut off a string?

Posted by Alex Farran on 06/30/05 12:04

writes:

> Hey all,
> I have a small CMS tool that users can leave a max 200 characters message.

> everthing is fine but IF someone does something like this:

> aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
> 200 characters long

> my whole layout bearks appart even when i use style="width:300px" etc

> so is there a premade function in php that splits my words?

Use wordwrap http://uk.php.net/manual/en/function.wordwrap.php

Example 2 does what you want -

<?php
$text = "A very long woooooooooooord.";
$newtext = wordwrap($text, 8, "\n", 1);

echo "$newtext\n";
?>

This example would display:

A very
long
wooooooo
ooooord.

--

__o Alex Farran - Open source software specialist
_`\<,_ PHP | MySQL | E-Commerce | Content Management
(_)/ (_) site: www.alexfarran.com blog: alexfarran.blogspot.com
phone:01273 474065 mobile:07790 389330

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация