- var_dump: documentation ( source)
- preg_match_all: documentation ( source)
- explode: documentation ( source)
<?php
$message = "
[xxxStudent.address_1xxx][xxxStudent.address_2xxx][xxxStudent.address_3xxx]
[xxxStudent.townxxx]
[xxxStudent.countyxxx]
[xxxStudent.postcodexxx]
[xxxStudent.country_iso_2xxx]";
preg_match_all('/\[xxx(\w+[\.+\w+]+)xxx\]/', $message, $tags, PREG_SET_ORDER);
foreach ($tags as $tag) {
$tag_parts = explode('.', $tag[1]);
if (count($tag_parts) == 1) {
$tag_model = null;
$tag_field = $tag[1];
} else if(count($tag_parts) == 2) {
$tag_model = $tag_parts[0];
$tag_field = $tag_parts[1];
}
var_dump($tag_model);
var_dump($tag_field);
}