Re: [PHP] Shortening a String

2003-10-28 Thread John W. Holmes
Jason Williard wrote:
I would like to display part of the output of a query.  In many cases,
the string returned by this query exceeds 200 characters.  Is there a
way to cut it off after 200 characters?  Even better, is there a way to
cut it off at the next space after 200 characters?
Read this thread for a lot of suggestions...

http://forums.devshed.com/showthread.php?threadid=23711

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals – www.phparch.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] Shortening a String

2003-10-28 Thread Jason Williard
Thanks.  That's exactly what I was looking for and is working perfectly.

- Jason


-Original Message-
From: Pablo Gosse [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, October 28, 2003 7:18 PM
To: Jason Williard; [EMAIL PROTECTED]
Subject: RE: [PHP] Shortening a String


On Tuesday, October 28, 2003 6:53 PM Jason Williard wrote:

> I would like to display part of the output of a query.  In many cases,
> the string returned by this query exceeds 200 characters.  Is there a
> way to cut it off after 200 characters?  Even better, is there a way
to
> cut it off at the next space after 200 characters?

This should do what you want.
 
substr($str,0,strpos($str,' ',200));

Cheers,
Pablo

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Shortening a String

2003-10-28 Thread Pablo Gosse

On Tuesday, October 28, 2003 6:53 PM Jason Williard wrote:

> I would like to display part of the output of a query.  In many cases,
> the string returned by this query exceeds 200 characters.  Is there a
> way to cut it off after 200 characters?  Even better, is there a way
to
> cut it off at the next space after 200 characters?

This should do what you want.
 
substr($str,0,strpos($str,' ',200));

Cheers,
Pablo

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Shortening a String

2003-10-28 Thread Martin Towell
substr($str, 0, 200);

or an (untested) ereg

ereg("(.{200}[^ ]*)", $str, $bits);

HTH
Martin

-Original Message-
From: Jason Williard [mailto:[EMAIL PROTECTED]
Sent: Wednesday, 29 October 2003 1:53 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Shortening a String


I would like to display part of the output of a query.  In many cases,
the string returned by this query exceeds 200 characters.  Is there a
way to cut it off after 200 characters?  Even better, is there a way to
cut it off at the next space after 200 characters?

Thank you for any assistance,
 - Jason

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php