Banner

Sponsor

Login


Welcome Back!
Guest
Guest

Register

Lost your password?

99 users online



Sperate Text

Sperate Text

Currently viewing this thread: 1 (0 members and 1 guests)


littleuseatall

littleuseatall

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.

schoi

schoi

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

littleuseatall

littleuseatall

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...

BigToach

BigToach

Neversidian
Status: Offline!
PHP:

<?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!

Quick Jump:

Main Navigation


Site & Graphic Design by Aeon Tan
Developed by Jeremie Pelletier & Scott Roach


NeverAPI generated this page in 0.0073 seconds.