View Full Version : How do you change data(PHP)

08 Nov 2006, 02:40 PM
Lets say i have a form thats comes in assigned to a variable, the user entered a zip code. Maybe 25637 for example. I want to be able get the first 3 of those 5 digits (256), how do i do that? where can i find the commands on how to edit user entered data.

i found one way, you can do a [1] [2] [3]

09 Nov 2006, 06:35 AM
this will split a string after a certain number of chararters - there are other ways of spliting string so try searching workwrap() or split() and you should find something that could help.


$text = "25637"; //zip code entered
$newtext = wordwrap($text, 3, " ", 1); //split the text after 3 characters - seporate with a space

echo "$newtext"; //display the message


this will display "256 37" tho which i think is not quite want you want.