I am literarily driving myself nuts with this problem.
I have this code in PHP:
 private function searchpage($data) {
  $file = @file_get_contents("./assets/template/search.html");
  $content = "";
  $pages = "";
 foreach ($data as $keys) {
 //var_dump($keys); This gives the correct information,I will show the    
 output later on.
        $content = str_replace("[PHOTO]",$keys['photo'], $file);
        $content = str_replace("[NAME]",$keys['name'], $content);
        $pages .= $content;
  }
 return $pages;
}
The var_dump from $keys looks like this
  array(1) { [0]=> array(7) { ["_id"]=> string(1) "2" ["_user"]=>    
  string(1) "1" ["_short"]=> string(4) "test" ["_long"]=> string(9)   
  "test long" ["name"]=> string(4) "test" ["_dat"]=> string(10) "2017-  
   08-29" ["photo"]=> string(92) "https://s-media-cache-     
   "}
as you can see, I use the correct name tags.
The STR_REPLACE doesn't work though. I keep getting this error:
Undefined index: name in     
/Applications/MAMP/htdocs/test/lib/_layout.php on line 144
Undefined index: photo in /Applications/MAMP/htdocs/test/lib/_layout.php on line 145
The strange thing is: I do EXACTLY the same thing on a different HTML page, and there it works perfectly.
I have no clue what's wrong with this code. I do request the function. The data I give to the function is correct. It does open the correct HTML page. The only thing which isn't correct is the str_replace.
 
    