I am trying to extract from each row what is in the value field. I am getting stuck as i need a substring with unknown start and end position. eg the name field i need the value 'wwwww', the email field i need the email value 'aa@gmail.com' etc .
exploded by id and this is the $arr array
(int) 0 => '{"name":{"',
(int) 1 => '":"name","type":"text","title":"","value":"wwww","raw_value":"wwww","required":true},"email":{"',
(int) 2 => '":"email","type":"email","title":"","value":"aa@gmail.com","raw_value":"aa@gmail.com","required":true},"phone":{"',
(int) 3 => '":"phone","type":"text","title":"","value":"55555","raw_value":"55555","required":true},"message":{"',
(int) 4 => '":"message","type":"textarea","title":"","value":"gjghjghj","raw_value":"gjghjghj","required":false}}'
$name=null;;
$email=null;
$phone=null;
$message=null;
foreach( $arr as $key => $item2):
if (strpos($item2,'"name"') !== false) {
$arr2=explode(':',$arr[$key+1]);
debug($item2);
debug('name:'.$arr2[1]);
$name=$arr2[1];
exit;
}
if (strpos($item2,'"email"') !== false) {
$arr2=explode(':',$arr[$key+1]);
// debug($arr2[0]);
// debug('email:'.$arr2[1]);
$email=$arr2[1];
}
if (strpos($item2,'"phone"') !== false) {
$arr2=explode(':',$arr[$key+1]);
// debug($arr2[0]);
// debug('phone:'.$arr2[1]);
$phone=$arr2[1];
}
if (strpos($item2,'"message"') !== false) {
$arr2=explode(':',$arr[$key+1]);
// debug($arr2[0]);
// debug('message:'.$arr2[1]);
$message=$arr2[1];
}
endforeach;
$form[$i]['id']= $item['meta_id'];
$form[$i]['name']= $name;
$form[$i]['email']= $email;
$form[$i]['phone']= $phone;
$form[$i]['message']= $message;
$i=$i+1;
// debug($arr);
endforeach;