I have a function to send mail to users and I want to pass one of its parameter as an array of ids.
Is this possible to do? If yes, how can it be done?
Suppose we have a function as:
function sendemail($id, $userid) {
}
In the example, $id should be an array.
You can pass an array as an argument. It is copied by value (or COW’d, which essentially means the same to you), so you can
array_pop()(and similar) all you like on it and won’t affect anything outside.You can in fact only accept an array there by placing its type in the function’s argument signature…
You can also call the function with its arguments as an array…