哪些php函数直接作用于变量?(类似于sort())


Which php functions act directly upon the variable? (like sort() )

实例:

$fruits = array("lemon", "orange", "banana", "apple");
$sort = sort($fruits);
var_export($sort);
var_export($fruits);

返回
true
array ( 0 => 'apple', 1 => 'banana', 2 => 'lemon', 3 => 'orange', )

sort()只返回bool值,不管它是否有效。函数作用于变量本身。而:

$s = 'thestring';
$trim = trim($s,'ing');
var_export($trim);
var_export($s);

的回报:

'thestr'
'thestring'

那么,发生了什么?这其中有什么规律或原因吗?哪些函数直接作用于变量?

编辑:"通过推荐",我明白了。因而:

function mytrimmer(&$string){
    $string = trim($string,'ing');
    return $string;
}
$s = 'thestring';
var_export(mytrimmer($s));
var_export($s);

返回
'thestr'
'thestr'

除了sort()之外,rsort()和shuffle()也作用于提供给函数的数组变量。