{"id":4411,"date":"2022-09-29T16:46:35","date_gmt":"2022-09-29T15:46:35","guid":{"rendered":"https:\/\/ibex.tech\/cloud\/?p=4411"},"modified":"2026-04-23T09:40:49","modified_gmt":"2026-04-23T08:40:49","slug":"array-values","status":"publish","type":"post","link":"https:\/\/ibex.tech\/cloud\/php\/forms\/array-values","title":{"rendered":"Array Values"},"content":{"rendered":"\n<h4 class=\"wp-block-heading\">Creating a field that will give an array when submitted<\/h4>\n\n\n\n<h5 class=\"wp-block-heading\">Form element<\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>  &lt;input type=\"checkbox\" name=\"UserIsActive&#91;$UserId]\" value=\"YES\" \/&gt;\n  &lt;input type=\"text\" name=\"UserName&#91;$UserId]\" value=\"\" \/&gt;<\/code><\/pre>\n\n\n\n<h5 class=\"wp-block-heading\">Form handler<\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>  if (isset($_POST&#91;'UserName']))\n  {\n    foreach ($_POST&#91;'UserName'] as $UserId => $UserName)    \/\/Will always be present\n    {\n      $IsActive = isset($_POST&#91;'UserIsActive']&#91;$UserId]);    \/\/Checkboxes will only be present when checked\n\n      \/\/$UserId\n      \/\/$UserName\n      \/\/$IsActive (true\/false)\n    }\n  }<\/code><\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Creating a field that will give an array when submitted Form element Form handler<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[44,42],"tags":[],"class_list":["post-4411","post","type-post","status-publish","format-standard","hentry","category-forms-html","category-forms"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/4411","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/comments?post=4411"}],"version-history":[{"count":3,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/4411\/revisions"}],"predecessor-version":[{"id":5382,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/4411\/revisions\/5382"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/media?parent=4411"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/categories?post=4411"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/tags?post=4411"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}