将"1小时19分钟"改为"1小时19分钟"

tha*_*lja 0 php replace

我有包含电影运行时间的字符串:

1 h 19 min
Run Code Online (Sandbox Code Playgroud)

现在我希望它看起来像这样:

1h 19m
Run Code Online (Sandbox Code Playgroud)

我知道这实际上应该很简单,但我无法找到解决方案.

flo*_*ree 6

$str = str_replace(array(' h', ' min'), array('h', 'm'), $str);
Run Code Online (Sandbox Code Playgroud)


mis*_*lee 5

$runtime="1 h 19 min";
$runtime=str_replace(" h","h",$runtime);
$runtime=str_replace(" min","m",$runtime);
Run Code Online (Sandbox Code Playgroud)