- var_dump: documentation ( source)
- preg_replace: documentation ( source)
<?php
$bcrypt = '$2a$12$9SIfjYSVOTw8xFn98DadmOYKMSyReSktMvm/tfiLFDYb.oGvO8LEC';
$bcryptNeedsRehash = preg_replace('/\$\d{2}\$/', '\$' . 12 . '\$', $bcrypt);
var_dump($bcrypt, $bcryptNeedsRehash);