array_filiter function receives the array to be filter as fisrt argument, and a callback defining the filter predicate as its second [closed] - php

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 12 hours ago.
Improve this question
$my_array =[1,2,3,4,5];
$even_numbers = array_filter($my_array, function ($number){ return $number % 2==0; });
The array_filiter function receives the array to be filter as fisrt argument, and a callback defining the filter predicate as its second.

Related

Spread argumnts function functionName(...$nums) [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 days ago.
Improve this question
I made a spread and it converts the Parameter to the array. it works fine but I don't understand how it happened.
The Code under below ::
function ava (...$nums){
return $nums;
}
Print_r (ava(100, 100, 100, 100));
also have a question of spread can be used with string by PHP ?

Muitiple Data (get) VALUES [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
need to put one more element to show in controller laravel, today 'status_viagem','=','VIAGEM' works finne but need´s 'VIAGEM' and 'DESCARGA'.
My controller:
public function listaPainel(Request $request)
{
$lista = Cco::where('status_viagem','=','VIAGEM')->get();
$data['lista'] = $lista;
return view('rast.lista_painel', $data);
}
Your question is not clear. I am guessing you want to compare with more data in where condition. In this case, you may need like this:
$lista = Cco::whereIn('status_viagem', ['VIAGEM', 'DESCARGA'])->get();
You need to be more clear about your problem.

How to add a strings with a numberical value in PHP [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
In my laravel controller, I get phone number from user input (01711111111). I want to add country code (88) with the user input, so total result will be like 880171111111. How can I add a string with the numerical value? This code shows error.
$client_phone=$request->phone_number;
$client_phone1='88'+$client_phone;
concatenation operator ('.')
$client_phone1 = '88' . $client_phone;

How to insert php post name into a variable? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
I have a post value named $_POST['John'] and I want to insert the post name "John" into a variable but not its value. How can I achieve this? Code Sample:
$_POST['John'] = "value";
array_keys is PHP function which is returning the keys from an array, you have only single array than we can use 0 as the key. if you have more than one array element you can use loop.
You can use array_keys as you mentioned there is one parameter use
$a = array_keys($_POST)[0];
https://3v4l.org/NUkkL

When we pass an array as an argument to a function, what actually gets passed? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
When we pass an array as an argument to a function, what actually gets passed?
Someone told me that it is "Base address of the array"? but I am not sure about it. How this array is processed then?
this is the answer: Are arrays in PHP passed by value or by reference?

Categories