$var1 = '1.1.2'; $var2 = '1.1'; if( index( $var1, $var2 ) == 0 ) { print "matches" } else { print "Doesn't match" }