<?php
$text = "aaaa Last name:aaa city:aaaa email:ddd";
$pos = strpos($text, 'Last');
$result = ($pos !== FALSE) ? trim(substr($text, 0, $pos)) : $text;
echo $result."\n";
$text = "aaaa Last name:aaa city:aaaa email:ddd";
$pos = stripos($text, 'last');
$result = ($pos !== FALSE) ? trim(substr($text, 0, $pos)) : $text;
echo $result."\n";
$text = "aaaa ast name:aaa city:aaaa email:ddd";
$pos = stripos($text, 'Last');
$result = ($pos !== FALSE) ? trim(substr($text, 0, $pos)) : $text;
echo $result."\n";