我如何得到<246.64260,167.12500,24.62500>来分隔变量?

Kev*_*erw 0 php

如果我有<246.64260, 167.12500, 24.62500>每个数字可以从1到256.我需要得到它为$ X为246,$ Y为167和$ Z为24

我该怎么办?我想要删除所有的空间,然后爆炸就可以了

X 246.64260
Y 167.12500
Z 24.62500

然后再次爆炸得到X 246 Y 167 Z 24

这是最好的方法吗?

hsz*_*hsz 7

$input  = '<246.64260, 167.12500, 24.62500>';
$output = str_replace(array('<','>',' '), '', $input);
$output = explode(',', $output);
$output = array_map('intval', $output);

list($X, $Y, $Z) = $output;
Run Code Online (Sandbox Code Playgroud)

  • [intval]上的array_map为+1(http://de3.php.net/manual/en/function.intval.php). (3认同)