Jump to content

Help Writing Conditional Statement


EK

Recommended Posts

I want to write a conditional statement like the following:

 

if ($value = "300x") {

 

however, I want this to work if x is changed to anything. So the conditional should work if the following is true:

 

if ($value = "300dog") {

 

or

 

if ($value = "300cat") {

 

How do I make it work as long as 300 is present regardless of what follows after. Thanks in advance!

Link to comment
https://forums.phpfreaks.com/topic/230648-help-writing-conditional-statement/
Share on other sites

hi,

 

try this solution

 

<?php

$paragraph = '300 had not been then, greece would not have been now';
$paragraph1 = 'if 300 had not been then, greece would not have been now';
$var1 = '300';

if (stripos($paragraph, $var1)=='0') {
echo 'it works';
}
else {
echo 'it doesnt';
}

?>

 

now try changing $paragraph with $paragraph1 in stripos.

 

Regards,

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.