Answer the question
In order to leave comments, you need to log in
Array_map or json_encode?
What is the difference in recording? Where, when and what to apply? Tell me please.
$my_array = array_map( 'strval', $_POST['pic_texts'] );
$my_array= json_encode( $_POST['pic_texts'] ));
Answer the question
In order to leave comments, you need to log in
array_map is used to traverse arrays. The scope is similar to foreach . Theoretically, you can write your own serialization mechanism with it, but in practice this is not necessary.
json_encode is used to serialize any objects (including multidimensional ones) into a string. Just like serialize .
If you try to apply the strval function to an array, you will get "Array to string conversion in ..." warnings, and the string "Array" as the value, regardless of the contents of the array.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question