sandy1028 Posted October 21, 2010 Share Posted October 21, 2010 I have the variables $cap and $url If the $cap contains any of the strings ".jpg,.JPG,.gif,GIF" I have to concatenate $url.$cap Quote Link to comment Share on other sites More sharing options...
mattal999 Posted October 21, 2010 Share Posted October 21, 2010 It's pretty simple really. I'm going to give you an answer in the form of code, but your "question" really is more of a statement. I would work on that if I were you. $imagetypes = array(".gif", ".jpg"); foreach($imagetypes as $type) { if(stripos($cap, $type) !== false) { // Use stripos for case insensitivity, or you could use strtolower($cap) in PHP4 $new = $url.$cap; } } Quote Link to comment Share on other sites More sharing options...
AbraCadaver Posted October 21, 2010 Share Posted October 21, 2010 Just for fun: $imagetypes = array(".gif", ".jpg"); if(in_array($cap, $imagetypes) || in_array($cap, array_map('strtoupper', $imagetypes))) { $url .= $cap; } //or if(in_array($cap, array_merge($imagetypes, array_map('strtoupper', $imagetypes)))) { $url .= $cap; } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.