jwhite68 Posted May 28, 2007 Share Posted May 28, 2007 Does anyone have any advice on how I can write a simple routine that can take a string that is received from a GET form action - knowing that the response will have data in this kind of format field 1: N(2) field 2: YYYYMMDDHHMMSS field 3: N[12] field 4: A[8] field 5: A[15] field 6: N[2] field 7: A[3] ie I know the format of the data coming back, but there are no delimiters or identifiers of any kind. So I want to take the data response received and split it into variables $field1, $field2 etc. Quote Link to comment https://forums.phpfreaks.com/topic/53284-splitting-up-a-string-response-into-separate-variables/ Share on other sites More sharing options...
MadTechie Posted May 28, 2007 Share Posted May 28, 2007 without delimitors your need to pad them to the exact length then use something like substr, just an idea 1 question, why are you doing it this way? Quote Link to comment https://forums.phpfreaks.com/topic/53284-splitting-up-a-string-response-into-separate-variables/#findComment-263309 Share on other sites More sharing options...
kenrbnsn Posted May 28, 2007 Share Posted May 28, 2007 Use the substr() function. You could probably use regular expressions also, but I don't use them often enough to give you a hint... Ken Quote Link to comment https://forums.phpfreaks.com/topic/53284-splitting-up-a-string-response-into-separate-variables/#findComment-263311 Share on other sites More sharing options...
jwhite68 Posted May 28, 2007 Author Share Posted May 28, 2007 Thanks. I was aware of substr, but was hoping for something a little more exciting. Anyway, in the absence of any other exciting way, I will use substr. Thanks again. Quote Link to comment https://forums.phpfreaks.com/topic/53284-splitting-up-a-string-response-into-separate-variables/#findComment-263426 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.