Replace Two colors with textures

I am using the following code to replace 2 colors with two different texture files, respectively.

<?php
$texture = imagecreatefrompng("_volanic_real.png");    
$lava = imagecreatefrompng("lava.png");    

//file needed to be changed
$src = imagecreatefrompng("tile1.png");     

//make base image transparent where $texture needs to go
$color = imagecolorclosest($src, 0, 148, 255);  //make blue transparent
imagecolortransparent($src, $color);
imagealphablending($src, false);
imagesavealpha($src, true);

//Put texture under transparent base image
$new = imagecreatetruecolor(50,50);
imagecopy($new, $texture, 0, 0, 0, 0, 50, 50);   
imagecopy($new, $src, 0, 0, 0, 0, 50, 50);   

//is this needed?
$new_c = imagecreatetruecolor(50, 50);
imagecopy($new_c, $new, 0, 0, 0, 0, 50, 50);    

//make place where 2nd texture $lava needs to go in new image transparent
$green = imagecolorclosest($new_c, 0, 127, 14);
imagecolortransparent($new_c, $green);
imagealphablending($new_c, false);
imagesavealpha($new_c, true);


//put $lava behind new base image
$new2 =  imagecreatetruecolor(50,50); 
  
imagecopy($new2, $lava, 0, 0, 0, 0, 50, 50);  
imagecopy($new2, $new_c, 0, 0, 0, 0, 50, 50); 

       
header( "Content-type: image/png" ); 
imagepng( $new2 );
imagedestroy($new2);
?>

I added comments to help anyone willing to help.

My problem is that although the first texture, _volcano_real.png, is replaced in the target image (tile1.png), the second texture doesn’t work (lava.png).

Let me know what you think I should do.