eval.in

Paste #661574

PHP — PHP 5.6.23, pasted 2 years ago (json)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<?php
$text = "myfildddddddddddddddddd.dddddddddd/ddddddd.ddddddddddddd/dddddd.dddddddddddddddddd.ename-qr.ZiP";


$time_start = microtime(true);
	$last = pathinfo($text, PATHINFO_EXTENSION);
$duration = number_format(microtime(true)-$time_start, 6);

echo "PathInfo did in ".$duration." seconds ";
var_dump( $last );


$time_start = microtime(true);
	$last = substr($text, strrpos($text, ".")+1);
$duration = number_format(microtime(true)-$time_start, 6);


echo "Substr did in ".$duration." seconds ";
var_dump( $last );

$time_start = microtime(true);
	$part=explode('.',$text);
	$last = array_pop($part);
$duration = number_format(microtime(true)-$time_start, 6);

echo "Explode did in ".$duration." seconds ";
var_dump( $last );

Program Output

PathInfo did in 0.000045 seconds string(3) "ZiP"
Substr did in 0.000018 seconds string(3) "ZiP"
Explode did in 0.000021 seconds string(3) "ZiP"

OK (0.008 sec real, 0.008 sec wall, 14 MB, 59 syscalls)

Fork