Jump to content

Call-time-pass-by-reference error.


alby

Recommended Posts

Hi,

 

I am receiving the following error within my code:

Call-time pass-by-reference has been deprecated; If you would like to pass it by reference, modify the declaration of array_multisort(). If you would like to enable call-time pass-by-reference, you can set allow_call_time_pass_reference to true in your INI file.

 

The code is shown below, the problem is that a reference is being passed to array multi-sort

 

function aasort(&$array, $args) {
/*Syntax: aasort($assoc_array, array("+first_key", "-second_key", etc..));

Example: aasort($db_array, array("+ID", "-AGE", "+NAME"));
Where the "+" in front of the keys stands for "ASC" and "-" for "DESC".

This sorts the array first ascending by "ID", then descending by "AGE" and
finally ascending by "NAME".		*/

foreach($args as $arg) {
	$order_field = substr($arg, 1, strlen($arg));
	foreach($array as $array_row) {
	        $sort_array[$order_field][] = $array_row[$order_field];
	}
	$sort_rule .= '$sort_array['.$order_field.'], '.($arg[0] == "+" ? SORT_ASC : SORT_DESC).',';
}
eval ("array_multisort($sort_rule".' &$array);');
}

 

Any ideas on how i can get round this would be greatly appreciated.

 

 

Link to comment
https://forums.phpfreaks.com/topic/58075-call-time-pass-by-reference-error/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.