什么是preg_match条件,以确保第一个数字是7?

For e.g.

if(preg_match("/[^0-9]/",$number_from)){
   $error_message .= 'Please Check and try again.<br />';
} 

is to only ensure numbers are entered for the string.

But what is the condition to ensure the first number can only be a number "7", or else the above error message will show?

Sorry im new to PHP.

The very simple regular expression suggested in comment:

/^7\d+$/

will match every string containing only digits and starting with 7 that, if I understand your question, is your validated string.

To check for errors, you can use this syntax:

if( ! preg_match( "/^7\d+$/", $number_from ) )
{
   $error_message .= 'Please Check and try again.<br />';
} 

The exclamation point ! in front of preg_match is a negation. It means: “If not match”.