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 > Short php question

Short php question
Thread Tools
Jaey
Mac Elite
Join Date: Dec 2003
Status: Offline
Reply With Quote
Feb 7, 2004, 06:14 PM
 
I know in JavaScript you have the handy 'charAt()' and 'indexOf()' functions... is there something like that in php? It would help me A LOT.
Thanks.
     
Simon Mundy
Grizzled Veteran
Join Date: Jun 2001
Location: Melbourne, Australia
Status: Offline
Reply With Quote
Feb 7, 2004, 07:08 PM
 
Originally posted by Jaey:
I know in JavaScript you have the handy 'charAt()' and 'indexOf()' functions... is there something like that in php? It would help me A LOT.
Thanks.
$dest = substr ($yourstring, startingat, howmanychars);

e.g.

$name = "Simon Mundy"
$name = substr($name,0,5);
echo $name;

prints "Simon";

Spend some time at www.php.net reading and re-reading the documentation if you get the chance - every time I visit I still learn something new, or find a better way to do things.
Computer thez nohhh...
     
Jaey  (op)
Mac Elite
Join Date: Dec 2003
Status: Offline
Reply With Quote
Feb 7, 2004, 07:17 PM
 
Ooh, that helps, thanks. That would take care of the charAt().
After reading some php.net documentation, I found that strpos would take care of the indexOf(). Thanks for that tip
     
   
 
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 01:56 AM.
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.,