- print_r: documentation ( source)
- preg_match_all: documentation ( source)
<?php
$txt = "My text \"can contain\" both single 'and double\"' quotes. The quotes \"can also be 'nested\" as you can see.";
if (preg_match_all('~(?|"([^"]*)"|\'([^\']*)\')~', $txt, $matches)) {
print_r($matches[1]);
}