gvilla23
asked on
PHP - compare varible
I just want to check a 3 digit number (integer) starts with a 10, the last digit can be any number.
So something like 10*
So something like 10*
ASKER
Thanks, but I am getting an error on if(preg_match('/10\d/'), $id){
here is my code.
thanks
$obj = simplexml_load_file('test. xml');
// ACTIVATE THIS TO VISUALIZE THE OBJECT
// var_dump($obj);
// IF WE HAVE A GET ARGUMENT
if (!empty($_GET["id"]))
{
// USE ONLY NUMBERS
$id = preg_replace('#[^0-9]#', NULL, $_GET["id"]);
// ITERATE OVER THE POPUP OBJECTS
foreach ($obj->popup as $popup)
{
// FIND THE MATCHING ID(S)
if ($popup->id == $id)
{
//$id = $id->id;
$id = (int)$popup->id;
$title = (string)$popup->title;
$img_loc = (string)$popup->img_loc;
$client = (string)$popup->client;
$involvement = (string)$popup->involvemen t;
// echo PHP_EOL . $title . ' ' . $client;
if (preg_match('/10\d/'), $id){
echo 'true';
}else{
echo 'false';
}
here is my code.
thanks
$obj = simplexml_load_file('test.
// ACTIVATE THIS TO VISUALIZE THE OBJECT
// var_dump($obj);
// IF WE HAVE A GET ARGUMENT
if (!empty($_GET["id"]))
{
// USE ONLY NUMBERS
$id = preg_replace('#[^0-9]#', NULL, $_GET["id"]);
// ITERATE OVER THE POPUP OBJECTS
foreach ($obj->popup as $popup)
{
// FIND THE MATCHING ID(S)
if ($popup->id == $id)
{
//$id = $id->id;
$id = (int)$popup->id;
$title = (string)$popup->title;
$img_loc = (string)$popup->img_loc;
$client = (string)$popup->client;
$involvement = (string)$popup->involvemen
// echo PHP_EOL . $title . ' ' . $client;
if (preg_match('/10\d/'), $id){
echo 'true';
}else{
echo 'false';
}
ASKER
if(preg_match('/(<a\s*'), $id)){
fixed that.. let me see if it works now
fixed that.. let me see if it works now
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
What is (<a\s*')?
if (preg_match('/10\d/'), $digitNumber){
echo 'true';
}else{
echo 'false';
}
Cheers