I'm developing a website using PHP which enables the creation on poster automatically. The users can choose between color themes which are defined on a php file like this:
$f_1 =array(
"1" => "#1e354c ",
"2" => "#ebcc85",
"3" => "#133745"
);
$f_3 =array(
"1" => "#1e354c",
"2" => "#b5cd9c",
"3" => "#133745"
);
$themes = array(
"Tema 1" => json_encode($f_1),
"Tema 2" => json_encode($f_3)
);
echo "<select class='form-control' id='themeselect' onchange='updatePoster()'>";
foreach($themes as $cc => $name) {
echo '<option value="' . $name . '">' . $cc . '</option>';
}
echo "</select>";
The JSON ecoding of $f_1
looks like this;
"{\"1\":\"#1e354c \",\"2\":\"#ebcc85\",\"3\":\"#133745\"}"
The problem is that the value of "Tema 1
" is "{
"
I also tried to use serialize()
instead of json_encode()
but that didn't work either.