Jump to content

String copy function help


louis_coetzee

Recommended Posts

Please help me, I want to read the values between the red text into different variables, for example:

|ACTIV|gvnE8HEsyivRyirwE|TRIME| =....... $active = gvnE8HEsyivRyirwE

 

(|ACTIV|gvnE8HEsyivRyirwE|TRIME|wpxFGswFxmJdcJF|CLAS1|gUGJxfJd|CLAS2|gUGJxfJd|SEVER|

Link to comment
Share on other sites

Assuming all the spacers are 7 characters long (as they are in your example) You can use this:

 

$string = '|ACTIV|gvnE8HEsyivRyirwE|TRIME|wpxFGswFxmJdcJF|CLAS1|gUGJxfJd|CLAS2|gUGJxfJd|SEVER|';

$split = str_split($string);
$parts = Array();
$j = -1;
for($i = 0;$i < count($split)-7;$i++)
{
if($split[$i] == '|'){ $i += 7; $j++;}
$parts[$j] .= $split[$i];
}

echo $parts[0] . '<br />'; //gvnE8HEsyivRyirwE
echo $parts[1] . '<br />'; //wpxFGswFxmJdcJF
echo $parts[2] . '<br />'; //gUGJxfJd
echo $parts[3] . '<br />'; //gUGJxfJd

 

You could probably also use Regex, I might post a regex solution in a few minutes.

Link to comment
Share on other sites

Assuming all the spacers are 7 characters long (as they are in your example) You can use this:

 

$string = '|ACTIV|gvnE8HEsyivRyirwE|TRIME|wpxFGswFxmJdcJF|CLAS1|gUGJxfJd|CLAS2|gUGJxfJd|SEVER|';

$split = str_split($string);
$parts = Array();
$j = -1;
for($i = 0;$i < count($split)-7;$i++)
{
if($split[$i] == '|'){ $i += 7; $j++;}
$parts[$j] .= $split[$i];
}

echo $parts[0] . '<br />'; //gvnE8HEsyivRyirwE
echo $parts[1] . '<br />'; //wpxFGswFxmJdcJF
echo $parts[2] . '<br />'; //gUGJxfJd
echo $parts[3] . '<br />'; //gUGJxfJd

 

You could probably also use Regex, I might post a regex solution in a few minutes.

Hi Alex,

Thanks a lot for your reply, the only problem would be that that was only part of one string, they differ eatch time, basically its all encrypted, except for the 7char part...

 

for example:(below)

I need to assighn eatch to a variable for example: |ACTIV| would be $active and the rest that follows, until the next one. basically need to take this, decrypt it, and display is in catagories in a table.

("|ACTIV|gLrS8wiSv0tg8H|TRIME|wpxFGswFxmJdcJF|CLAS1|nFbTdslddU9xlcJGsYxcpspJhlcUcU x9xce.|CLAS2|pJhlcUcU x9slTJfcd|SEVER|oJslYlFJsU2scpJsFxdN!|DESCR|yFJTflf9esxf9FJldJdscpJsFxdNscUsGJPJjUhspJhlcUcU x9xce.s82sGFbTsxdsmJcluUjxCJGsxfscpJsjxPJF,slPUxGsGFbTdsYxcpslsjUfTsGbFlcxUfsU2sl9cxUf.soJdcsxdscUsdJJNsGFbTsfUcsmJcluUjxCJGsxfsjxPJF.|SPRIO|2")(|ACTIV|gLrS8wiSv0tg8H|TRIME|wpxFGswFxmJdcJF|CLAS1|H6LL|CLAS2|0ldcJFsDFUbh:sgLrS8wiSv0tg8H|SEVER|6dJsGFbTsUfjesYpJFJscpJsuJfJ2xcsqbdcx2xJdscpJsFxdNscUscpJs2Jcbd.swpJsGFbTsGUJds9lFFeslsFxdN.|DESCR|SxdNs2l9cUFsgs:srfxmljsdcbGxJdsdbTTJdcspxTpsFxdNs-sjxmxcJGspbmlfsGlclslPlxjlujJ.soJdcslPUxGJG.|SPRIO|3)("|ACTIV|gLrS8wiSv0tg8H|TRIME|RJ9UfGswFxmJdcJF|CLAS1|nFbTdslddU9xlcJGsYxcpspJhlcUcU x9xce.|CLAS2|pJhlcUcU x9slTJfcd|SEVER|oJslYlFJsU2scpJsFxdN!|DESCR|yFJTflf9esxf9FJldJdscpJsFxdNscUsGJPJjUhspJhlcUcU x9xce.s82sGFbTsxdsmJcluUjxCJGsxfscpJsjxPJF,slPUxGsGFbTdsYxcpslsjUfTsGbFlcxUfsU2sl9cxUf.soJdcsxdscUsdJJNsGFbTsfUcsmJcluUjxCJGsxfsjxPJF.|SPRIO|2")(|ACTIV|gLrS8wiSv0tg8H|TRIME|RJ9UfGswFxmJdcJF|CLAS1|H6LL|CLAS2|0ldcJFsDFUbh:sgLrS8wiSv0tg8H|SEVER|6dJsGFbTsUfjesYpJFJscpJsuJfJ2xcsqbdcx2xJdscpJsFxdNscUscpJs2Jcbd.swpJsGFbTsGUJds9lFFeslsFxdN.|DESCR|SxdNs2l9cUFsgs:srfxmljsdcbGxJdsdbTTJdcspxTpsFxdNs-sjxmxcJGspbmlfsGlclslPlxjlujJ.soJdcslPUxGJG.|SPRIO|3)("|ACTIV|gLrS8wiSv0tg8H|TRIME|1xFdcswFxmJdcJF|CLAS1|nFbTdslddU9xlcJGsYxcpspJhlcUcU x9xce.|CLAS2|pJhlcUcU x9slTJfcd|SEVER|oJslYlFJsU2scpJsFxdN!|DESCR|yFJTflf9esxf9FJldJdscpJsFxdNscUsGJPJjUhspJhlcUcU x9xce.s82sGFbTsxdsmJcluUjxCJGsxfscpJsjxPJF,slPUxGsGFbTdsYxcpslsjUfTsGbFlcxUfsU2sl9cxUf.soJdcsxdscUsdJJNsGFbTsfUcsmJcluUjxCJGsxfsjxPJF.|SPRIO|2")(|ACTIV|gLrS8wiSv0tg8H|TRIME|1xFdcswFxmJdcJF|CLAS1|H6LL|CLAS2|0ldcJFsDFUbh:sgLrS8wiSv0tg8H|SEVER|6dJsGFbTsUfjesYpJFJscpJsuJfJ2xcsqbdcx2xJdscpJsFxdNscUscpJs2Jcbd.swpJsGFbTsGUJds9lFFeslsFxdN.|DESCR|SxdNs2l9cUFsgs:srfxmljsdcbGxJdsdbTTJdcspxTpsFxdNs-sjxmxcJGspbmlfsGlclslPlxjlujJ.soJdcslPUxGJG.|SPRIO|3) 

Link to comment
Share on other sites

Mine will work fine, it only shows the last couple because that's what I put it to do, instead just remove those echos, and put print_r($parts); when you run it on the full string it'll show the array that contains all the parts.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.