$tem = $arr [' Invoice_type '];
echo "
";
Print_r ($tem);
Output
A:2:{s:4: "Type"; A:3:{i:0;s:8: "Personal invoice"; I:1;s:8: "Enterprise Invoice"; i:2;s:0: "";} S:4: "Rate"; a:3:{i:0;d:6;i:1;d:6;i:2;d:0;}}
$teem []= preg_replace ('!s: (\d+): "(. *?)";! Se ', ' s: '. strlen (' $ "). ': \ ' $2\ "; '", $arr [' Invoice_type ']);
echo "";
Print_r ($teem);
Output
Array
(
[0] = = a:2:{' s: '. strlen (' type '). ': ' type '; ' a:3:{i:0; ' S: '. strlen (' personal Invoice '). ': ' Personal invoice '; ' I:1; ' S: '. strlen (' Corporate Invoice '). ': ' Corporate invoice '; ' I:2; ' S: '. strlen ('). ': ""; '} ' S: '. strlen (' rate '). ': "Rate"; ' a:3:{i:0;d:6;i:1;d:6;i:2;d:0;}}
)
$teemm []= preg_replace_callback ('!s: (\d+): "(. *?)";! S ', function ($matches) {return strlen (' $ "). ': \ ' $2\ "; ';}, $arr [' Invoice_type ']);
echo "";
Print_r ($TEEMM);
Output
Array
(
[0] = = a:2:{2:\ "$2\", a:3:{i:0;2:\ "$2\"; i:1;2:\ "$2\"; i:2;2:\ "$2\";} 2:\ "$2\"; a:3:{i:0;d:6;i:1;d:6;i:2;d:0;}}
)
How to let the Preg_replace_callback output the same information as the preg_replace output
Reply to discussion (solution)
I don't know what you're doing.
The result of the instance is not right!
The second output is mistaken.
$teem []= preg_replace ('!s: (\d+): "(. *?)";! Se ', ' s: '. strlen (' $ "). ': \ ' $2\ "; '", $arr [' Invoice_type ']);
echo "
";
Print_r ($teem);
Output
Array
(
[0] = = a:2:{s:4: "type"; A:3:{i:0;s:8: "Personal invoice"; I:1;s:8: "Enterprise Invoice"; i:2;s:0: "";} S:4: "Rate"; a:3:{i:0;d:6;i:1;d:6;i:2;d:0;}}
)
I don't know what you're doing.
The result of the instance is not right!
The second output is mistaken.
$teem []= preg_replace ('!s: (\d+): "(. *?)";! Se ', ' s: '. strlen (' $ "). ': \ ' $2\ "; '", $arr [' Invoice_type ']);
echo "";
Print_r ($teem);
Output
Array
(
[0] = = a:2:{s:4: "type"; A:3:{i:0;s:8: "Personal invoice"; I:1;s:8: "Enterprise Invoice"; i:2;s:0: "";} S:4: "Rate"; a:3:{i:0;d:6;i:1;d:6;i:2;d:0;}}
)
$s = Preg_replace_callback ('/s:\d+: "(. +?)"; S ', function ($r) {$n = strlen ($r [1]), return "s: $n: \" $r [1]\ ";";}, $s);
$s = Preg_replace_callback ('/s:\d+: "(. +?)"; S ', function ($r) {$n = strlen ($r [1]), return "s: $n: \" $r [1]\ ";";}, $s);
God, I changed the output data as you did.
Code
$teem = Preg_replace_callback ('/s:\d+: "(. +?)"; S ',
function ($r) {
$n = strlen ($r [1]);
Return "s: $n: \" $r [1]\ ";";
}, $arr [' Invoice_type ']);
echo "";
Print_r ($teem);
Output
A:2:{s:4: "Type"; A:3:{i:0;s:8: "Personal invoice"; I:1;s:8: "Enterprise Invoice"; I:2;s:12: "";} S:4: "Rate"; a:3:{i:0;d:6;i:1;d:6;i:2;d:0;}}
Enterprise Invoice behind s:0: "" changed to S:12: "" more than 12 length, this How to come
The case of empty value is not considered
Put '/s:\d+: ' (. +?) "; S
The case of empty value is not considered
Put '/s:\d+: ' (. +?) "; S
Change to '/s:\d+: ' (. *?) "; S
Thank you very much