pctechtime Posted January 12, 2007 Share Posted January 12, 2007 I am trying to input a string of numbers and have it go into 4 different fields of a database. See belowAny help would be great. data to input 0215446912345678scan_field // this is the field the above number would go into and also needs to be broken up into the fields belowitem_number // this is the field the first 6 numbers would go intograde // this is the field the next 2 numbers would go intoserial_number // this is the field the last numbers would go into (the last set of numbers can be 1 to many in length Link to comment https://forums.phpfreaks.com/topic/33899-spliting-a-string-of-numbers/ Share on other sites More sharing options...
kobmat Posted January 12, 2007 Share Posted January 12, 2007 You may want to look into the substr function on php documentation Link to comment https://forums.phpfreaks.com/topic/33899-spliting-a-string-of-numbers/#findComment-159165 Share on other sites More sharing options...
Psycho Posted January 12, 2007 Share Posted January 12, 2007 This:[code]<?php$input = "0215446912345678";$scan_field = $input;$item_number = substr($input, 0, 6);$grade = substr($input, 6, 2);$serial_number = substr($input, 8);echo "Scan Field: " . $scan_field . "<br>";echo "Item number: " . $item_number . "<br>";echo "Grade: " . $grade . "<br>";echo "Serial number: " . $serial_number . "<br>";?>[/code]Produces this:[code]Scan Field: 0215446912345678Item number: 021544Grade: 69Serial number: 12345678[code][/code][/code] Link to comment https://forums.phpfreaks.com/topic/33899-spliting-a-string-of-numbers/#findComment-159168 Share on other sites More sharing options...
pctechtime Posted January 12, 2007 Author Share Posted January 12, 2007 This is great thank you so much Link to comment https://forums.phpfreaks.com/topic/33899-spliting-a-string-of-numbers/#findComment-159171 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.