0

below is my code.

All is okay but, in image alt tag, its showing $image_alt, instead value of that variable. How can I print the value of the variable inside this function?

Kind regards.

$image_alt = $attributes["caption"];
$image_src= Str_replace('src="', 'alt=$image_alt  src="',$image_src);
  • 2
    Use double quotes (`"`) instead of single quotes (`'`) in order to print out the variable value. – Ahmad Feb 28 '23 at 13:52
  • You can print out the double quote after `src` by escaping it. `"alt=$image_alt src=\""` – aynber Feb 28 '23 at 13:59
  • I have written now in that way, $image_src= Str_replace("src='", "alt=$image_alt src='",$image_src); Did you mean that?@Ahmad – Rubel Ahmed Feb 28 '23 at 14:11

0 Answers0