0

Hey.. I have some hard time finding the * in the value... The preg_match should find it.

Here is the code... I have put it in a value the * and preg_match should find it, and if it does it should make the echo "Insert a positive number please"; If preg_match do not find the * than output the $value

<?php

 $value2 = -10 * 10;
 $value = ($value2 - ($value2 + $value2));

 if(!$value || $value > 0 || !is_numeric($value) || preg_match("/*/", $value2))
 {
   echo "Insert a positive number please";
 }
 else 
 { 
   echo $value;
 }
?>
flag

1 Answer

0

* is a special character in regex and needs to be escaped. Try this:

preg_match("/\*/", $value2)
link|flag

Your Answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.