This function has the behavior many of us dreamed of for its JS homonym !

function parseInt($s) {
    return ((int) preg_replace('~[^0-9]+~', '', $s));
}