[ create a new paste ] login | about

Link: http://codepad.org/N5tc8hPp    [ raw code | output | fork ]

PHP, pasted on Feb 8:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<?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";


Output:
1
2
3
aaaa
aaaa
aaaa ast name:aaa city:aaaa email:ddd


Create a new paste based on this one


Comments: