| Quick Question regarding: Only variables should be passed by reference
|
tec4

msg:4493876 | 4:41 pm on Sep 11, 2012 (gmt 0) | Just want to better understand why I'd be getting this error: Strict Standards: Only variables should be passed by reference in /directory...
$to_email = Array(); foreach($_POST as $key => $value) { if(stripos($key, "contact_") === 0) { $id = array_pop(explode("_", $key)); $to_email[] = $id; } } But when I change it to the below code, it works fine
$to_email = Array(); foreach($_POST as $key => $value) { if(stripos($key, "contact_") === 0) { $id = explode("_", $key); $id = array_pop($id); $to_email[] = $id; } } Is it as simple as you are not supposed to modify a string or value from it's original form without actually storing it as it's 'new' value?
|
lostdreamer

msg:4494621 | 7:36 am on Sep 13, 2012 (gmt 0) | $id = array_pop(explode("_", $key));
There's your problem ;) explode will return an array. Array_pop will take that array, and remove the last value from it. But since you are not supplying Array_pop with an array (but rather a function that returns an array) it cannot modify the array for you. [php.net...]
|
tec4

msg:4495570 | 8:57 pm on Sep 15, 2012 (gmt 0) | Haha thanks :P Ya, that makes sense. Just hadn't really toyed much with this stuff I guess - but your explanation cleared it up. Much appreciated!
|
|
|