- array_map: documentation ( source)
- print_r: documentation ( source)
- preg_match_all: documentation ( source)
- trim: documentation ( source)
<?php
$string = "aa | bb | \"cc | dd\" | 'ee | ff'";
preg_match_all("~(?|\"([^\"]*)\"|'([^']*)'|([^|'\"]+))(?:\s*\|\s*|\z)~", $string, $matches);
print_r(array_map(function($x) {return trim($x);}, $matches[1]));