- preg_match: documentation ( source)
- print_r: documentation ( source)
<?php
$string = 'this is some sample';
$base = 'this is some sample [shortcode/ attr="somth"]dfdfdfdf[shortcode]text[/shortcode][shortcodeniedzialajacy]';
$pattern = "/\[(shortcode)([ ][a-zA-Z0-9\"'=\\s]*\\]|\\])/";
$matches = array();
preg_match($pattern, $string, $matches);
print_r($matches);