So, I have the following php:
<?php
$user_id = get_current_user_id();
$user_number= get_user_meta($user_id, 'number', false);
$numbers= print_r($user_number);
?>
I get the following:
Array
(
[0] => Array
(
[1] => 769099
[2] => 768785
[3] => 769135
[4] => 769118
[5] => 769136
[6] => 769122
[7] => 769130
)
)
Now, I am trying to use in_array to add a condition as following:
<?php if (in_array ($number_id, $numbers)){?>
where $number_id is one of the number in the array.
I have two questions:
Do I have to use print_r to get the values instead of simply saying Array in order to use in_array?
How do I actually user in_array? in this case?
(For example, using the get_user_meta, I simply get Array. I don't want to use print_r. How do I do this? Thanks!)
in_array ($number_id, $numbers[0])0and1?[0]means the index of thearrayyou want to check