I'm using CodeIgniter and I wrote the following code in one of my model (.php file) to do preg_split operation on one column value for each rows matching the query.
For context, I have no idea how to do debugging such backend operation and am lost / afraid of blowing up the database. The problem is I don't know if I'm doing the preg_split operation on a string or an array value.
The field type for fruits column is varchar(32) which is a string, but would calling $row['fruits'] really return a pure string?
$query = $this->db->query($sql);
foreach ($query->result_array() as $row) {
// theoretically $s = 'apple banana'
$s = $row['fruits'];
// theoretically parts[0]=apple, parts[1]=banana
$parts = preg_split('/\s+/', $s);
}
var_dump,print_r. Or what?