How can i make this code work? TY!
$site = '1'
$mysites = array('1', '2', '3', '4', '5', '6');
foreach($mysites as $mysite)
{
echo $mysites; **but not the site with value 1**
}
A simple if
will suffice:
$site = '1';
$mysites = array('1', '2', '3', '4', '5', '6');
foreach($mysites as $mysite)
{
if ( $mysite !== '1' )
{
echo $mysite;
}
}
or if you wan't to check against the $site
variable:
$site = '1';
$mysites = array('1', '2', '3', '4', '5', '6');
foreach($mysites as $mysite)
{
if ( $mysite !== $site )
{
echo $mysite;
}
}
$site = '1'
$mysites = array('1', '2', '3', '4', '5', '6');
foreach($mysites as $mysite) {
if ($mysite == $site) { continue; }
// ...your code here...
}
Just use an if
statement:
foreach($mysites as $mysite) {
if ($mysite !== $site) {
echo $mysite;
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With