This is my array:
$class = $row["class"];
$classes = array( '1', '2', '4', '5', '6', '7', '8', '9', '10', '11'
);
$replacements = array( 'Warrior', 'Paladin', 'Hunter', 'Rogue',
'Priest', 'Death Knight', 'Shaman', 'Mage', 'Warlock', 'Monk',
'Druid' );
$resultclass = str_replace( $classes, $replacements, $class );
My problem thou is that when i get the number 11 from the DB it displays "Warrior" twice and not "Druid"
How can i fix that?
$resultclass = strtr($class , $classes, $replacements);1and the11in your $classes array, so first it will replace 11 and later on 1 xDReplacement order gotcha Because str_replace() replaces left to right, it might replace a previously inserted value when doing multiple replacements. See also the examples in this document.