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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.