Jump to content

Stumped on loop if statement..


Recommended Posts

If I have code that looks something like this:


$t = array('one','two','three','_four','_five','_six');
$u = 'five';
foreach ($t as $v) {
if (substr($v,0,1) != '_') { // if begins with an underscore, remove it, unless it is equal to _$u
	echo $v.'<br />';


I am trying to take out all array items that begin with an underscore except the one that is equal to this..




something like


$v == '_'.$u


So what should be echoed is this:







Is there any way to do this with only an if, and not an if/else??



Link to comment
Share on other sites


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.