I'm tasked to change the framework from CakePHP to Codeigniter. In the database there is this JSON like text in one column in order to define the values of 4 select inputs. The text looks like -
a:4:{i:58;s:1:"1";i:59;s:1:"0";i:60;s:1:"0";i:61;s:1:"0";}
Basically it says a(array size which is 4), i(being the id) and in s(i dont know about the first integer but all of its values is just 1 the second integer with the "" means it is the 0=>'None', 1=>'Yes', 2=>'NaN').
This is the previous programmer's code in CakePHP
<?php
$options_services = array(0=>'None', 1=>'Yes', 2=>'NaN');
?>
<div class="box-body">
<div class="form-group ">
<div class="row">
<div class="col-md-6">
<label> Select Service Category</label>
<div>
<?php echo $this->Form->input('catservice_id', array('options'=>$catservices,'div' => false, 'label' => false, 'class' => 'form-control','type'=>'select','empty'=>'Please Select Category')); ?>
</div>
</div>
<div class="col-md-6">
<label> Title <span class="required">*</span></label>
<div>
<?php echo $this->Form->input('title', array('div' => false, 'label' => false, 'class' => 'form-control')); ?>
</div>
</div>
</div>
</div>
<div class="form-group ">
<div class="row">
<?php if(!empty($service_list)): ?>
<?php foreach($service_list as $key=>$values): ?>
<div class="col-md-3">
<label><?php echo $values;?> </label>
<div>
<?php echo $this->Form->input('cleaning.'.$key, array('options'=>$options_services,'div' => false, 'label' => false, 'class' => 'form-control','type'=>'select')); ?>
</div>
</div>
<?php endforeach; ?>
<?php endif; ?>
</div>
</div>
</div><!-- /.box-body -->
<div class="box-footer">
<?php
echo $this->Html->link('Back', array('controller' => 'services', 'action' => 'index'), array('escape' => false, 'class' => 'btn btn-info'));
?>
<button type="submit" class="btn btn-primary">Submit</button>
</div>
i certainly means id
i want to use the JSON like text to be able to use this
I tried json_decode
in Codeigniter but it doesnt work. You guys have any idea how I can decode this? Would help me a lot. Thank you!