I want to check if JSON array in the databse has a value. Every value corresponds to a WordPress category ID. (For example, "elevator" = 120)
If it does exist, I need to push it to an array called $features so that I can later run a script that creates WordPress post where this array of exsisting numbers (IDs) are inserted to a post, like this on this example:
$my_post = array(
'post_title' => $post_title,
'tax_input' => array(
'property_category' => array( $features )
The main code (I know I might be far off):
$options = explode(",",$db->options);
$features = array();
switch ($features) {
case in_array("basement", $options) && "basement" != false:
array_push($features,145);
break;
case (in_array("bathtub", $options) && "bathtub" != false):
array_push($features,167);
break;
case (in_array("boiler", $options) && "boiler" != false):
array_push($features,105);
break;
}