My var_dump is returning this:
array(5) {
["radioinput"]=> string(12) "sidebar-left"
["option1"]=> int(0)
["sometext"]=> string(0) ""
["selectinput"]=> NULL
["sometextarea"]=> string(0) ""
}
I’m having problems acting on the “radioinput” array.
If it’s “sidebar-left” I want it to echo:
<body class="sidebar-left">
If it’s “sidebar-right” I want it to echo:
<body class="sidebar-left">
If it’s “two-sidebars” I want it to echo:
<body class="two-sidebars">
If it’s blank I want it to echo:
<body class="sidebar-left">
My questions is, how can I get my code to do this?
<?php
if (radioinput('sidebar-left')) {
echo '<body class="sidebar-left">';
} elseif (radioinput('sidebar-right')) {
echo '<body class="sidebar-right">';
} elseif (radioinput('two-sidebars')) {
echo '<body class="two-sidebars">';
} else {
echo '<body class="sidebar-left">';
}
?>
The way you are addressing your array isn’t correct. I am assuming that the array is going to be called
$data.or replace
$datawith whatever you had onvar_dump(...)Then, you code would look like:
Edit: You can even simplify that down to:
Cheers 🙂