Answer the question
In order to leave comments, you need to log in
How to convert an array of strings to an array of numbers?
Good day!
There is an array from POST
<input type="checkbox" name="answer[$id][]" value="$id_2">
array(1) {
[56]=>
array(2) {
[0]=>
string(3) "197"
[1]=>
string(3) "200"
}
}
$answer = $_POST['answer'];
$answer = array_map('intval', $answer);
array(1) {
[56]=>
int(1)
}
Answer the question
In order to leave comments, you need to log in
For some reason it comes out...
[56 => ['197', '200']]
. Here you are in the map and get intval(['197', '200'])
.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question