Extract a substring between two characters in a string PHP

use this code

$input = "[modid=256]";
preg_match('~=(.*?)]~', $input, $output);
echo $output[1]; // 256

working example http://codepad.viper-7.com/0eD2ns

Leave a Comment