• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Solved [PHP] Print array

troja

SD 2014
Joined
Jan 1, 2009
Messages
2,116
Reaction score
54
Hello, I've work'd abit with a custom AAC, just 4 fun.

Tho, I've one problem. My PHP code is like this
PHP:
	while($row = mysql_fetch_array($data))
	{
		$search  = array('Elder Druid', 'Master Sorcerer', 'Royal Paladin', 'Elite Knight', 'Druid', 'Sorcerer', 'Paladin', 'Knight');
		$replace = array('ED', 'MS', 'RP', 'EK', 'D', 'S', 'P', 'K');
		echo $row['name'];
		echo $row['level'];
		$subject = $row['vocation'];
		echo str_replace($search, $replace, $subject);
	}
This works, but. When it display character's vocation, it prints a number. So, 1 = ED, 2 = MS etc. But, I want it to print ED, MS etc instead.

I've tried print_r but I don't really like the result;
Array[0] => 'Elder druid', or however it was. :p

Thanks,
 
Last edited:
Why not just like:
Code:
$vocations = array('MS', 'ED', 'RP', 'EK');

(...) MYSQL things (...)

echo $vocations[$row['vocation']];
 
Also put array outside loop (while), you don't need to re-define it every time you loop through players.
 
Back
Top