Home >Backend Development >PHP Tutorial >请问怎么找最小的变量,而不是最小的值是多少

请问怎么找最小的变量,而不是最小的值是多少

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-23 14:24:341095browse

请问怎么找最小的变量,而不是最小的值是多少,最小值的位置也可以。

比如:
$a=1;
$b=2;
$c=3;


回复讨论(解决方案)

$_t = get_defined_vars();$a=1;$b=2;$c=3;$t = array_diff_key(get_defined_vars(), $_t, array('_t' => ''));echo array_search(min($t), $t); //a

获取到了那个变量后打印变量名

function varName( $v ) {    $trace = debug_backtrace();    $vLine = file( __FILE__ );    $fLine = $vLine[ $trace[0]['line'] - 1 ];    preg_match( "#\\$(\w+)#", $fLine, $match );    print_r( $match );}

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn