- preg_match: documentation ( source)
- print_r: documentation ( source)
<?php
$pattern = '/^.*(?=.{8,})(?=.*[a-z])(?=.*[A-Z])(?=.*[\d])(?=.*[\W]).*$/i';
$sample = 'Pderas12!';
echo (int)preg_match( $pattern, $sample, $matches).PHP_EOL;
print_r($matches);