I have several string's (id-question-18, id-answer-18, id-question-17, id-answer-17)
I needed to just write (id Question, id Answer, id question, id answer)
How do I do in PHP?
The goal is as follows:
At this point I have the following array that comes from a $ _POST
array(28) { ["privacidade-16"]=> string(1) "1" ["verificada-16"]=> string(1) "1" ["idPergunta-16"]=> string(2) "16" ["resposta-16"]=> string(5) "vitor" ["privacidade-17"]=> string(1) "1" ["verificada-17"]=> string(1) "1" ["idPergunta-17"]=> string(2) "17" ["resposta-17"]=> string(10) "2015-10-09" ["privacidade-18"]=> string(1) "1" ["verificada-18"]=> string(1) "1" ["idPergunta-18"]=> string(2) "18" ["idRespostaPre-18"]=> string(2) "19" ["privacidade-19"]=> string(1) "1" ["verificada-19"]=> string(1) "1" ["idPergunta-19"]=> string(2) "19" ["resposta-19"]=> string(3) "Rua" ["privacidade-20"]=> string(1) "1" ["verificada-20"]=> string(1) "1" ["idPergunta-20"]=> string(2) "20" ["idRespostaPre-20"]=> string(2) "22" ["privacidade-21"]=> string(1) "1" ["verificada-21"]=> string(1) "1" ["idPergunta-21"]=> string(2) "21" ["resposta-21"]=> string(4) "4465" ["privacidade-30"]=> string(1) "1" ["verificada-30"]=> string(1) "1" ["idPergunta-30"]=> string(2) "30" ["idRespostaPre-30"]=> array(4) { [0]=> string(3) "186" [1]=> string(3) "187" [2]=> string(3) "188" [3]=> string(3) "189" } }
What I need is to separate this array into an array with multiple arrays inside and would have to separate it as follows
an array with: array [0] = ["privacy"] = > string (1) "1" ["verified"] = > string (1) "1" ["questionID"] = > string (2) "16" ["answer"] = > string (5) "vitor"
array [1] = ["privacy-17"] = > string (1) "1" ["verified-17"] = > string (1) "1" ["questionID"] = > string (2) "17" ["answer"] = > string (10) "2015-10-09"
array [2] = ["privacy"] = > string (1) "1" ["verified"] = > string (1) "1" ["questionID"] = > string (2) "18" ["idResetPre"] = > string (2) "19"
Thereafter, this is because the fields that come from the POST are dynamic or are today 10 but tomorrow may be 20