我试图创建一个与魔兽世界相关的工具提示。
有些描述
<img src='images/interface/icons/inv_offhand_1h_ulduarraid_d_01.png' width='24' height='24'> Rest of description
如何将此字符串更改为
self.ref.child("users/(user.uid)/username").setValue(username)
非常感谢
答案 0 :(得分:1)
如果您100%确定字符串格式相同,则可以执行以下操作:
<?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;
{{3}}
结果:
<img src="images/interface/icons/inv_offhand_1h_ulduarraid_d_01.png" width="24" height="24"> Rest of description