
November 19th, 2006
10:40 PM
Neverside Newbie
Status: Offline!
Sperate Text
How do I grab the number 12 and 13 integers from a form (textfield) input?? Say I have a form that is accepting 13 numbers of input . . . . if a person types in 13 numbers I want to store the last two in a different variable from the 1-11 numbers. If they only type 11 then I do nothing and move on with just the one variable...
Anyone understand? In python I would simply apply the result to a list and "2ndvariable = pop(thelist[12,13])", but I am lost in PHP.
Thanks again guys.

November 20th, 2006
03:01 AM
funny and cheeky
Status: Offline!
I<?php
$number = strrev(chunk_split (strrev($number), 3,' '));
//If $number is '1234567', result is '1 234 567'.
?>
I got this from php.net. Am guessing if u do
$str = chunk_split($str,11," ");
http://www.w3schools.com/php/php_forms.asp
http://uk.php.net/manual/en/function.chunk-split.php

November 20th, 2006
10:35 PM
Neverside Newbie
Status: Offline!
Great. This works, but how do I get the second half into a new variable? $str just becomes the same input, but with spaces...

December 1st, 2006
11:45 AM
Neversidian
Status: Offline!
<?php
$str = '12345678910111213';
if(preg_match('/1213$/ms', $str))
{
$last = '1213';
$str = '1234567891011';
}
?>
Is there more variablility in the string than that, like spaces or non sequential numbers
___________________
Neverside Development Director
PHP Snippets
BigToach.com - IT WORKS, TOACHY!