Hey y'all.

I hope someone can shed some light on what I am needing to do. Just a little guidance should be good...

What I have is an app where an employee slides their id badge and a form captures the long string of data from the magnetic strip on the back. I need to take the string that is read and convert it into two(2) separate variables. What I thought would be a simple task has got me beat....

Example of the full string:

%B1500000000000015^EMPLOYEEID/SMITH John^031110100000019301000000877000000?;500000000000015=0305101193010877?

First Variable from string:
$StringVar1 = %B1500000000000015^EMPLOYEEID/SMITH John^031110100000019301000000877000000?;

Second Variable from string:
$StringVar2 = %B1500000000000015^EMPLOYEEID/SMITH John^031110100000019301000000877000000?;

If any one could toss me a bit of direction that would be great.

<?php

$full = '%B1500000000000015^EMPLOYEEID/SMITH John^031110100000019301000000877000000?;500000000000015=0305101193010877?';
$chunks = explode('?', $full);
echo $chunks[0] . '?';

?>

It looks like you want the value of $StringVar2 to equal that of $StringVar1. Is that correct?

<?php

$full = '%B1500000000000015^EMPLOYEEID/SMITH John^031110100000019301000000877000000?;500000000000015=0305101193010877?';
$chunks = explode('?', $full);
echo $chunks[0] . '?';

?>

It looks like you want the value of $StringVar2 to equal that of $StringVar1. Is that correct?

Thanks, and I messed up the post(need to edit it)
The second string needs to be this part:

;500000000000015=0305101193010877?

The "?" are the line ending breaks.

Thank You for your input thus far, (edit point)actually, that may have solved my issue...let me give it the ol college try here and see...will let you know.

is there no way to edit the original post?

If not, this is to clerify:

First Variable from string:
$StringVar1 = %B1500000000000015^EMPLOYEEID/SMITH John^031110100000019301000000877000000?

Second String:
;500000000000015=0305101193010877?


I am truly sorry for the confusion everyone. I read the post three times before I put it up there (I am spacing out a lot here today...maybe a vacation).

Member Avatar for nevvermind
<?php
$string = '%B1500000000000015^EMPLOYEEID/SMITH John^031110100000019301000000877000000?;500000000000015=0305101193010877?';

// for PHP 5.3.0+
$sub_string1 = strstr($string, ';', true);
$sub_string2 = strstr($string, ';');

// for earlier versions of PHP than 5.3.0
$substr = explode(';', $string);

$sub_string1 = $substr[0];
$sub_string2 = ';' . $substr[1];

?>

Perfect!
Thank you both for you efforts!
Now I just have to get the rest of the functions built in to check the EmpId # and validate the date and and and and and and and.....LOL

Seriousl though thank you again ( I can not believe I could not figure that one out...sigh...maybe I was over thinking it....)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.