how to make str_replace in a loop for database elements from a query in php - Hack The Tech - Latest News related to Computer and Technology

Hack The Tech - Latest News related to Computer and Technology

Get Daily Latest News related to Computer and Technology and hack the world.

Friday, September 30, 2022

how to make str_replace in a loop for database elements from a query in php

it is necessary to replace each {} similar element from the layout that we get from the database with data from another table . I have a lot of rows in the anamnes_rows table and I need to replace each $anamnes_stubbs with this variable -> $anamnes_db there will be a foreach loop here, but I don't understand how to use it

  while($row_anamnes = $result_anamnesquery->fetch()){
                              
        $anamnes_db = array($number, $row_anamnes['TERM'], $row_anamnes['CONS'], $row_anamnes['CONT'], $row_anamnes['id']);
        $anamnes_stubs = array("{NUMBER}", "{TERM}", "{CONS}", "{CONT}", "{ID}");
        $tbody = $form_array[2]; // here is a piece of the desired layout obtained by the index after explode
        $change_arr = str_replace($anamnes_stubs, $anamnes_db, $tbody);
      }


source https://stackoverflow.com/questions/73900080/how-to-make-str-replace-in-a-loop-for-database-elements-from-a-query-in-php

No comments:

Post a Comment