preg_replace_callback は preg_replace
$tem = $arr['invoice_type'];
echo "
";<br />print_r($tem);<br />output<br />a:2:{s を置き換えます:4:"タイプ";a:3:{i:0;s:8:"個人請求書";i:1;s:8:"企業請求書";i:2;s:0:"";} s:4:"レート";a:3:{i:0;d:6;i:1;d:6;i:2;d:0;}}<br /><br />$teem []= preg_replace('!s:(d ):"(.*?)";!se', "'s:'.strlen('$2').':"$2";'", $arr['invoice_type' ] );<br />echo "<pre class="brush:php;toolbar:false">";<br />print_r($teem);<br />出力<br />配列<br />(<br /> [0] => a:2:{' s:'.strlen('type').':"type";'a:3:{i:0;'s:'.strlen('個人請求書').':"個人請求書";'i: 1;'s:'.strlen('Enterprise Invoice').':"Enterprise Invoice";'i:2;'s:'.strlen('').':"";'}'s:'。 strlen('レート').':"レート";'a:3:{i:0;d:6;i:1;d:6;i:2;d:0;}}<br>)<br><br>$teemm []= preg_replace_callback('!s:(d ):"(.*?)";!s', function ($matches) {return strlen('$2').':"$2 ";';}, $arr['invoice_type'] );<br>echo "<pre class="brush:php;toolbar:false">";<br>print_r($teemm);<br>output<br>Array<br>(<br> [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;}}<br>)<br><br> preg_replace_callback に preg_replace と同じ情報を出力させる方法 <br><font color="#FF8000">-----解決策---------</font><br><div class="code" style="position:relative; padding:0px; margin:0px;"><pre class="brush: php">$s = preg_replace_callback('/s:\d+:"(.+?)";/s',<br /> function($r) {<br /> $n = strlen($r[1]);<br /> return "s:$n:\"$r[1]\";";<br /> }, $s);<br />