Home Only variables should be passed by reference Strict standards on line 138
Reply: 1

Only variables should be passed by reference Strict standards on line 138

ravi topa
1#
ravi topa Published in 2018-02-13 09:49:43Z

This question already has an answer here:

  • Only variables should be passed by reference 9 answers
usort($qus_with_ans, "qus_sort");
$ary_val = max(array_column($qus_with_ans, 'updated_at'));
$ary_key = array_search($ary_val, array_column($qus_with_ans, 'updated_at'));
$k = $qus_with_ans[$ary_key];
$curnt_sub_id = $k['subject_id'];
$curnt_sub_name = $k['s_name'];
$last_question_key = end(array_keys($qus_with_ans));

We have a error Strict standards: Only variables should be passed by reference on last line of code i can't understand why error comes Please fix my issue line no. 138 are $last_question_key = end(array_keys($qus_with_ans));

Butuzov
2#
Butuzov Reply to 2018-02-13 09:52:45Z

You can't use function return in end function and should convert it to the variable.

$keys=array_keys($qus_with_ans);
$last_question_key = end($keys);

However, use arrya_pop which is pushing-out last element from the array

$last_question_key = array_pop(array_keys($qus_with_ans));

If you anyway don't have intension to use keys elsewhere from performance point of view.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.381195 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO