phpmysqlmysqlistdclassezsql

how to print stdclass object name to data


i used ezsql mysqli and my mysql scheme:

    id---settingname------settingcode
---------------------------------
0    doctype          <!DOCTYPE html>
1    html_lang        en
2    charset          utf8

and my php code

<?php echo $doctype; ?>
<html lang="<?php echo $html_lang; ?>">
<meta charset="<?php echo $charset; ?>">

how can i fetch stdclass object like this with ezsql mysqli;

echo $settings['doctype'];

Solution

  • Ok, i found the answer, you can change index with array_column() like this;

    $settings = array_column($dbresult,'settingcode','settinguniquename');
    

    and you can print this variable like this;

    echo $settings['doctype']; echo $settings['charset']; echo $settings['anysettingname'];