What is the difference between a lookahead and lookbehind assertion in regular expressions, and how are they used in PHP?

Lookahead and lookbehind assertions are used in regular expressions to match patterns that are followed by or preceded by another pattern, without including the matched pattern in the final result. Lookahead assertions are denoted by `(?=...)` for positive lookahead and `(?!...)` for negative lookahead, while lookbehind assertions are denoted by `(?<=...)` for positive lookbehind and `(?<!...)` for negative lookbehind. Example PHP code snippet:

$string = &quot;apple orange banana&quot;;
$pattern = &quot;/\w+(?=\sorange)/&quot;; // positive lookahead to match words before &quot;orange&quot;
preg_match($pattern, $string, $matches);
echo $matches[0]; // Output: apple