<code><span>$configData</span>=<span>array</span>( <span>'1'</span>=><span>'11111111000111111'</span>, <span>'3'</span>=><span>'22222222000222222'</span>, <span>'4'</span>=><span>'33333333000333333'</span>, <span>'5'</span>=><span>'44444444000444444'</span>, <span>'6'</span>=><span>'55555555000555555'</span>, <span>'7'</span>=><span>'66666666000666666'</span>, <span>'7'</span>=><span>'77777777000777777'</span>, <span>'9'</span>=><span>'77777777000777777'</span>, ); <span>foreach</span>(<span>$configData</span><span>as</span><span>$key</span>=>&<span>$val</span>){ <span>$val</span>=str_replace(<span>'000'</span>,<span>'A'</span>,<span>$val</span>); <span>echo</span><span>$val</span>.<span>'<br/>'</span>; } <span>echo</span><span>'<pre class="brush:php;toolbar:false">'</span>; var_dump(<span>$configData</span>);</code>
以上就介紹了[php] 對數內的字串用str_replace進行替換的技巧,包括了方面的內容,希望對PHP教程有興趣的朋友有所幫助。