There are two arrays:

$needles = []; $replacements = []; 

values ​​are passed to them. in the first array the values ​​of the text, in the second with what to replace them. I try to replace:

 $html = preg_replace($needles, $replacements, $html); 

I end up with an empty string. Php 7 version, how will it be more correct to replace? $ html line is quite large, maybe this is the case?

  • so what are $ needles? Maybe there the whole line is completely matched and replaced with a void? - jekaby
  • The docks say preg_replace($patterns, $replace, '{startDate} = 1999-5-27'); Respectively, the first parameter is an array with patterns to be, not text - Alexey Shimansky
  • I think the problem is that the patterns are wrong. To be able to answer your question, you need to provide more data, for example: which strings lie in both arrays, which strings you try to parse, which is still in $html : an empty string or null (which behaves like an empty string, if treat it as a string)? - Michael Sivolobov

1 answer 1

Solved the problem, preg_replace replaced by str_replace .