str_replace函数无法替换多个值[重复]

This question already has an answer here:

I have set of strings and need to replace them using str)replace as we loop through the query as the query is success need to replace each value in PHP.

<?php

include_once("con.php");
$db = new Da();

$con = $db->con();

$lclString = "{{ONE}} {{TWO}} {{THREE}} {{FOUR}} {{FIVE}} {{SIX}}";

 $lclCount = 1;
 if(preg_match_all("/\{\{[^{}]+\}\}/", $lclString, $matches)) {

    foreach ($matches[0] as $match) {

        $lclQuery = "SELECT link, link_value FROM student WHERE link_value = '".$match."'";

        $lclResult = $connString->query($lclQuery);

        while($row = $lclResult->fetch(PDO::FETCH_ASSOC)) {

            $lclNewValue = str_replace($match, $row['link'], $lclString);

            }

        }

        echo json_encode($NewValue);

 } 

?>

Here only second replacement is happening.

</div>
<?php

include_once("con.php");
$db = new Da();

$con = $db->con();

$lclString = "{{ONE}} {{TWO}} {{THREE}} {{FOUR}} {{FIVE}} {{SIX}}";

 $lclCount = 1;
 if(preg_match_all("/\{\{[^{}]+\}\}/", $lclString, $matches)) {
 $lclNewValue = $lclString;
foreach ($matches[0] as $match) {

    $lclQuery = "SELECT link, link_value FROM student WHERE link_value = '".$match."'";

    $lclResult = $connString->query($lclQuery);

    while($row = $lclResult->fetch(PDO::FETCH_ASSOC)) {

        $lclNewValue = str_replace($match, $row['link'], $lclNewValue);

        }

    }

    echo json_encode($NewValue);

 } 

?>