I'm doing a particular exercise on a deserialized string in PHP. In practice, this string once serialized-deserialized by the webapp takes and joins the two fields 'id' and 'uid' and then adds them together to form a single 4-digit field.
example:
O: 8: "userdata": 3: {s: 4: "role"; s: 5:"admin"; s: 2: "id"; i: 21; s: 3: "uid"; i: 32 ;}
the webapp will give me the result: welcome admin 2132
I need to create an incremental numeric loop in order to have the id and uid field 2 cyclic digits that is:
O: 8: "userdata": 3: {s: 4: "role"; s: 5: "admin"; s: 2: "id"; i: 00; s: 3: "uid"; i: 00 ;}
O: 8: "userdata": 3: {s: 4: "role"; s: 5: "admin"; s: 2: "id"; i: 00; s: 3: "uid"; i: 01 ;}
and so on, until the uid field reaches 99 and the id field starts adding +1 and becoming 01 while the uid field must always do the same cycle.
i mean this:
O: 8: "userdata": 3: {s: 4: "role"; s: 5: "admin"; s: 2: "id"; i: 00; s: 3: "uid"; i: 99 ;}
O: 8: "userdata": 3: {s: 4: "role"; s: 5: "admin"; s: 2: "id"; i: 01; s: 3: "uid"; i: 00 ;}
O: 8: "userdata": 3: {s: 4: "role"; s: 5: "admin"; s: 2: "id"; i: 01; s: 3: "uid"; i: 01 ;}
O: 8: "userdata": 3: {s: 4: "role"; s: 5: "admin"; s: 2: "id"; i: 01; s: 3: "uid"; i: 02 ;}
I created this script so that I have 4 incremental digits but the problem is that I can't declare 2 digits in the id field and another 2 digits in the uid field in order to have the result I need.
<?php
for($a=0; $a< 10; $a++)
{
for($b=0; $b< 10; $b++)
{
for($c=0; $c< 10; $c++) {
for($d=0; $d< 10; $d++) {
$y = ($a . $b. $c. $d);
$plain = 'O:8:"userdata":3:{s:4:"role";s:5:"admin";s:2:"id";i:'.$y.';s:3:"uid";i:'.$y.';}';
echo $plain. "\n";
}
}
}
}
?>
The output of these for loops is nothing more than:
O:8:"userdata":3{s:4:"role";s:5:"admin";s:2:"id";i:0000;s:3:"uid";i:0000;}
O:8:"userdata":3{s:4:"role";s:5:"admin";s:2:"id";i:0001;s:3:"uid";i:0001;}
O:8:"userdata":3{s:4:"role";s:5:"admin";s:2:"id";i:0002;s:3:"uid";i:0002;}
O:8:"userdata":3{s:4:"role";s:5:"admin";s:2:"id";i:0003;s:3:"uid";i:0003;}
O:8:"userdata":3{s:4:"role";s:5:"admin";s:2:"id";i:0004;s:3:"uid";i:0004;}