<?php 'A' => 'Arbuz', 'B' => 'Banan'); $str = 'A jest smaczny, B jest zgniły'; ?>
jak, za pomoca preg_replace() zrobic, zeby $str reprezentowal napis: "Arbuz jest smaczny, Banan jest zgniły"
<?php $str = 'A jest smaczny, B jest zgniły'; foreach ($arr as $key => $value) { //print $key . $value; } ?>
<?php function createRegex($string) { return ('/' . $string . ' /'); } function addSpace($string) { return ($string . ' '); } preg_replace(array_map('createRegex', array_keys($arr)), array_map('addSpace', $arr), $str, 1) . '<br />'; ?>