This is a discussion on "Splitting a variable" within the PHP Forum section. This forum, and the thread "Splitting a variable are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
Splitting a variable
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
#1
|
|||
|
|||
|
Splitting a variable
I have a 8 digit variable im taking from a database which I want to split in the 2-2-4 digits i.e. 12345678 -> 12 34 5678 does anyone know if its possible.
|
|
|
|
#2
|
|||
|
|||
|
Re: Splitting a variable
Sorted it now, for anyone thats interested its
$variable = AABBCCCC; $CCCC = $variable % 10000; //CCCC $BB = ($variable-$CCCC)/10000 % 100; //BB $AA = ($variable-$BB)/1000000 % 100; //AA |
|
#3
|
|||
|
|||
|
Another way to do this is using the substr function (http://uk.php.net/substr):
string substr ( string string, int start [, int length] ) |
|
#4
|
||||
|
||||
|
Re: Splitting a variable
djme..... I should put your reply in the webforumz hall of fame and frame it!!!
The most hillarious cack handed code bodge I've seen in ages.. ROFL... classic
__________________
Click the 'Thanks!' button if this post has helped you Rob - Webforumz Founder
Last Blog Entry: Creative Labs threaten developer over home made drivers.... (Apr 1st, 2008)
Last edited by Rob; Apr 23rd, 2006 at 20:18. |
|
#5
|
|||
|
|||
|
Re: Splitting a variable
LOL I didn't realise there was a function to do it - I learnt it from a C++ book a few years ago and then thought it might work for this!
|
|
#6
|
|||
|
|||
|
Re: Splitting a variable
|
![]() |
| Tags |
| splitting, variable |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| variable classes | CloudedVision | PHP Forum | 4 | Feb 14th, 2008 03:07 |
| I'm used to just splitting tables, how can I do this in css? | mad samuel | Web Page Design | 2 | Aug 10th, 2007 17:36 |
| is this variable right? | geyids | PHP Forum | 4 | Aug 6th, 2007 21:45 |
| Site Splitting | Ross H | Webforumz Cafe | 2 | Mar 18th, 2007 16:16 |
| Need help on image splitting | sovereign6 | Graphics and 3D | 3 | Jul 14th, 2005 17:44 |