Hi I have a problem with strtr()
.
I am creating a website where users can add their emoticons, and call them inside their posts by typing in the special code for an emoticon.
This is what I have done and it works to some extent:
//FETCH FROM THE DB
while ( $row = mysql_fetch_array($fetch)) {
$table[] = array(
$row['shortcuttag1'] => "<img class='x' src='" . $row['tag1smilo'] . "' />",
$row['shortcuttag2'] => "<img class='x' src='" . $row['tag2smilo'] . "' />",
$row['shortcuttag3'] => "<img class='x' src='" . $row['tag3smilo'] . "' />",
$row['shortcuttag4'] => "<img class='x' src='" . $row['tag4smilo'] . "' />",
$row['shortcuttag5'] => "<img class='x' src='" . $row['tag5smilo'] . "' />"
);
This creates a multidimensional array with emoticons uploaded by one user.
When I use strtr($txt,$table[0])
, it works with the array[0] and the others, but I want to change the special code to emoticons that are located in and around all the subarrays.
Therefore, what I have done is to merge the array like so:
$oneDim = call_user_func_array('array_merge',$table);
I got the one dimensional array with all SpecialCode => Image fields.
But the strtr($txt,$oneDim)
stopped working with that; it is not showing anything.
I am worried because I have tried a few different ways to merge the array other than call_user_func_array()
and it gives the same result.
Maybe there is someone that could help me with that. I will be very grateful.
Thanks