Str_replace not working,to extract data from mysqli

I want something like this
$smiley=mysqli_fetch_assoc(myqli_query($con,“select * from smiley”));
$text=$smiley[‘textforchange’];
$imageadress=’’;

$room=mysqli_fetch_assoc(myqli_query($con,“select * from rooms”));
$txt=$room[‘text’];

$output=str_replace($text, $imageadress, $txt);
And now
Echo $output;
Is not working?help

Without a sample of your data and what result you expect, we cannot help with the actual problem.

The posted code has mysqli misspelled, is just fetching the 1st row from each table, is selecting all the columns (which is both wasteful and doesn’t tell us what your column naming is or if the fetch code is using anything that was selected), and you are replacing any found text with an empty string.

I expect img smiley,but i want to find that from sql table,i have table with adress and with code,and if is same code from rooms with table smiley(code) to output image adress from that code which exist in table smiley

I want like this code
$smiley= array(’$smileytable[‘codes’]’ => 'image adress $smileytable[‘adressfromuploadedimage’]);
$replace=str_replace(array_keys($smiley), array_values($smiley), $roomtext);

you can use array_combine to build up the replacement map and then use strtr on any string. But you should fix what @phdr said first.

Sponsor our Newsletter | Privacy Policy | Terms of Service