Jump to content

Check and concatenate


sandy1028

Recommended Posts

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;
    }
}

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;
}

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.