Reputation: 23
I'm trying to create a tooltip related to world of warcraft.
Some descriptions have
|TInterface\ICONS\inv_offhand_1h_ulduarraid_d_01:24:24:1.75:1.75|t Rest of description
how can I change this string into
<img src='images/interface/icons/inv_offhand_1h_ulduarraid_d_01.png' width='24' height='24'> Rest of description
Many thanks
Upvotes: 2
Views: 44
Reputation: 46650
If your 100% sure the string will be in the same format you can do it like the following.
<?php
$string = '|TInterface\ICONS\inv_offhand_1h_ulduarraid_d_01:24:24:1.75:1.75|t Rest of description';
$part = explode('|', $string);
list($url, $width, $height) = explode(':', $part[1]);
$description = substr($part[2], 2);
$url = substr(strtolower(str_replace('\\', '/', $url)), 1);
echo '<img src="images/'.$url.'.png" width="'.$width.'" height="'.$height.'"> '.$description;
Result:
<img src="images/interface/icons/inv_offhand_1h_ulduarraid_d_01.png" width="24" height="24"> Rest of description
Upvotes: 1