Jump to content


variable chopping


3 replies to this topic

#1 Av-

    I Feel Left Out

  • Members
  • PipPipPipPip
  • 1,971 posts
  • Gender:Male
  • Location:10 ft. below sea level

Posted 21 November 2005 - 04:15 PM

so basicly i want only the first 2 characters of a variable and chop of the rest.
know what im talking about,
like Alabama becomes AL, or Idaho ID, so if you know something to capitalize them aswell it would be even better.

#2 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 21 November 2005 - 04:25 PM

I believe i've told you this before, but use php.net, it has answers to all the questions you can think to ask (don't ask me how, just take my word).
http://php.net/manua...tion.substr.php
http://php.net/manua....strtoupper.php

Also note, since i'm assuming you're using this to get state abbreviations, how would you do New Jersey/New York?

#3 Av-

    I Feel Left Out

  • Members
  • PipPipPipPip
  • 1,971 posts
  • Gender:Male
  • Location:10 ft. below sea level

Posted 21 November 2005 - 04:35 PM

well, no, i was just using the states as an example :D
well thanks anyway, you helped me out :)
and i did look at php.net btw, i just didnt know what to search for

#4 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 21 November 2005 - 04:40 PM

Guide to php.net

If you're looking for some sort of string modification, look for things that have "str" in them.

If you want to do something with array's. Search for "array" and then find the array() function on that page, click the link. Look in the left hand nav for everything you can do to arrays.

Same concept for everything else (i.e. for anything dealing with an image, search for "image" and work fromt here).





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users