PHP's microtime() returns something like this:
0.56876200 1385731177 //that's msec sec
That value I need it in this format:
1385731177056876200 //this is sec msec without space and dot
Currently I'm doing something this:
$microtime = microtime();
$microtime_array = explode(" ", $microtime);
$value = $microtime_array[1] . str_replace(".", "", $microtime_array[0]);
Is there a one line code to achieve this?
You can do the entire thing in one line using regex:
Example:
Output:
DEMO
Unfortunately, due to PHP's restriction for float presentation (till 14 digits for whole numeric), there's little sense in using
microtime()
withtrue
as parameter.So, you'll have to work with it as with string (via
preg_replace()
, for example) or adjustprecision
to use native function call:-so, it will be like:
-still not "one-liner", but you're aware of reason that causes such behavior so you can adjust
precision
only once and then use that.