$a = "[480p]\/storage\/458f706a\/hls\/stream_2.m3u8,[720p]\/storage\/458f706a\/hls\/stream_1.m3u8,[1080p]\/storage\/458f706a\/hls\/stream_0.m3u8";
preg_match_all('/(\[480p\].*?),/', $a, $m);
var_dump($m[1][0]);
$a = "[480p]\/storage\/458f706a\/hls\/stream_2.m3u8,[720p]\/storage\/458f706a\/hls\/stream_1.m3u8,[1080p]\/storage\/458f706a\/hls\/stream_0.m3u8";
$a = explode('[480p]', $a);
if (isset($a[1])) {
$a = explode(',', $a[1]);
var_dump('[480p]' . $a[0]);
}
var parts = 'слово1 слово2 [слово слово слово] слово3 [слово] [слово слово ] слово4'.split(' ');
var res = [], flag = false;
for(var i = 0, il = parts.length; i < il; ++i){
var f = flag;
if(parts[i][0] === '[') flag = true;
if(parts[i][parts[i].length-1] === ']') flag = false;
if(f) res[res.length-1] += ' '+parts[i];
else res[res.length] = parts[i];
}
console.log(res);