Since google only gives the opposite answer of what i am needing (typed boolean to int php and it kept giving me int to boolean #thanksgoogle).
I am currently using checkboxes in a form, and wanting to save the checkbox value into a database that only has a int. What would be the best way to do this? i already tried casting it to a int but that didn't seem to work.
HTML: <input name='sticky' id='sticky' ng-model='formData.sticky' type="checkbox"> Sticky </br>
PHP:
$active = (int) $_POST['active'];
echo $active;
echo $_POST['active'];
Output:
0
true
Note: I am trying to do this as clean as possible, i know i can use a simple if statement or a switch. but is there no built in thing?
Aucun commentaire:
Enregistrer un commentaire