Jump to content

[SOLVED] request help with if statement


slashpine

Recommended Posts

Hi, can someone please show me how to use an array rather than a single word string?

if ($query=='painters')

echo "hellow world";[/php

 

how can I get the echo results if the query is any of the following..."painters","pressure_washing", "property_maintenance", "contractors". ?

 

Thanks in advance...

Link to comment
https://forums.phpfreaks.com/topic/136962-solved-request-help-with-if-statement/
Share on other sites

 

In place of - my first answer was too longwinded!

 

Note this checks every array in case $query is in more than one.

 

$things=array("painters","pressure_washing", "property_maintenance", "contractors");
$otherthings=array("builders","cleaning", "something", "something_else");

$query="painters";

if (in_array($query,$things)) echo "in things array";
if (in_array($query,$otherthings)) echo "in otherthings array";

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.