Hello. On the Internet there is a cloud of examples of how to replace the values of one array with another. But nowhere (in a few hours) I didn’t find how to replace only those values that meet certain criteria in the array.
Here the array_replace or str_replace can replace the values of a single Array(0=>'odin',1=>'dva',2=>'tri'); Array(0=>'one',1=>'two',2=>'three');
But I just can not figure out how to replace only part of the line, so that something like this happens:
// было так Array(0=>'odin',1=>'dva',2=>'tri'); // а хочу получить так Array(0=>'o(d)[i]n',1=>'(d)va',2=>'tr[i]'); Those. replace the letter i with [i] and replace the letter d with (d)
The only option I can implement is this (but I would like an option with regulars):
foreach(Array(0=>'odin',1=>'dva',2=>'tri')as$y=>$z) { // дальше с каждым значением работать отдельно, // а после всё собирать в отдельный массив }
foreachline of the formdata[$y] = str_replace("d", "[d]", $z)or an analogue with regular expressions, it is not clear. - teran