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
https://forums.phpfreaks.com/topic/163776-string-copy-function-help/
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.

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) 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.