Jump to content

regex syntax problem


robos99

Recommended Posts

The regex should be:
"/^[0-9]+$/" or "/^\d+$/"

You can also use typcasting and convert the value to a number, using (float) $var, (int) var, settype(), and so on

[code]<?php

echo $_GET['d'] . '<br />';
echo (preg_match("/^\d+$/", $_GET['d'])) ? 'true' : 'false';

?>[/code]
Link to comment
https://forums.phpfreaks.com/topic/11745-regex-syntax-problem/#findComment-44492
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.