0

How can I check if the content of preg_replace function is numeric/alphanumeric or not?

e.g.

if numeric :

$link= preg_replace("'\< (.*)\>'Ui","< <a href=\"x.php?id=\\1\">\\1</a>>",$link);

else

$link= preg_replace("'\< (.*)\>'Ui","< <a href=\"x.php?word=\\1\">\\1</a>>",$link);
Haza
  • 2,991
  • 1
  • 16
  • 13

1 Answers1

0

Have a look on ctype_alnum() function

bool ctype_alnum ( string $text )

Checks if all of the characters in the provided string, text, are alphanumeric. In the standard C locale letters are just [A-Za-z].

Haza
  • 2,991
  • 1
  • 16
  • 13