- var_dump: documentation ( source)
- preg_match_all: documentation ( source)
- trim: documentation ( source)
- preg_replace: documentation ( source)
<?php
$lines ="From: {Name|1} {Email|11}
Phone / Skype: {Phone / Skype|8} removeIfEmpty
Message Body:
{Tell us more|9} removeIfEmpty
Sender's IP: {ip}
{refUTM}
--
This e-mail was sent from a contact form on Software Development Company - Redwerk (http://redwerk.com)";
$pattern = "/^.*\bremoveIfEmpty\b.*$/m";
$matches = array();
preg_match_all($pattern, $lines, $matches);
foreach($matches as $match) {
preg_replace("/removeIfEmpty/", $match, "");
var_dump(trim($match));
}