sql - Extract a substring between two characters in a string PHP -
is there php function can extract phrase between 2 different characters in string? substr();
example:
$string = [modid=256]; $first = "="; $second = "]"; $id = substr($string, $first, $second);
thus $id
256
any help appreciated :)
use code
$input = "[modid=256]"; preg_match('~=(.*?)]~', $input, $output); echo $output[1]; // 256
working illustration http://codepad.viper-7.com/0ed2ns
php sql substr
No comments:
Post a Comment