Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Substring in PHP?

Substring in PHP?
Thread Tools
Zimwy
Dedicated MacNNer
Join Date: May 2002
Location: Brooklyn, NY
Status: Offline
Reply With Quote
Jun 6, 2003, 02:59 AM
 
Hi,
I was wondering how to do this:

[php]
$big_string = "Hello out there, how are you?"
$substring = substring(0,12,$big_string);
[/php]

so that now substring would have "hello out th". Any advice?

Thanks!
gabe
     
bluedog
Mac Elite
Join Date: Aug 2000
Location: Minneapolis, MN
Status: Offline
Reply With Quote
Jun 6, 2003, 07:56 AM
 
$big_string = "Hello out there, how are you?";
$substring = substr($big_string,0,12);

I believe that's what you want.

Then you can view the result with:

echo $big_string;
echo $substring;
( Last edited by bluedog; Jun 6, 2003 at 03:14 PM. )
     
aleph_null
Dedicated MacNNer
Join Date: Jan 2001
Location: Boulder, CO, USA
Status: Offline
Reply With Quote
Jun 6, 2003, 12:56 PM
 
This and so much more documented at php.net.
     
Colonel_Panic
Junior Member
Join Date: Aug 2002
Location: 127.0.0.1
Status: Offline
Reply With Quote
Jun 6, 2003, 05:21 PM
 
On PHP.net you just have to type the function you want on the end of the URL, I don`t know if you knew that or not. ( http://php.net/substring )

Also check out this site if you have any more PHP questions Its really good for help.
     
Gee4orce
Professional Poster
Join Date: Dec 2000
Location: Staffs, UK
Status: Offline
Reply With Quote
Jun 10, 2003, 06:01 AM
 
An absolutely excellent resource is O'Reilly's PHP Cookbook. Buy it. I subscribe to the online Safari version (safari.oreilly.com) and use it all the time.

Not only do you learn how to do something, you learn why to do it that way, why that way is best, and a couple of alternative ways of doing it.

Of course, I also downloaded the PHP documentation, which is a very thorough reference.
     
   
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 10:57 PM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,