Use PHP's foreach command to convert all PHP input into an array and set it to a JSON file in the form of key-value pairs - Solved
P粉883223328
2023-08-09 13:26:09
<p>I have a page that contains multiple radio buttons and I use a foreach loop to loop through the names of all radio buttons and another foreach loop at the top of the page to get the names of all radio buttons as keys and values. </p>
<pre class="brush:php;toolbar:false;"><?php
$radios=["name"=>"Display name","profile"=>"Display profile","phone"=>"Display phone number"];
$setting=[
"Some text"=>"its value"]
foreach($radios as $key=>$value){
$setting[]=$value=>$_POST[$value];
}
// it won't work
?></pre>
Not sure what you want to achieve, but that code doesn't look valid: