Jump to content

Basic query - find a string within a string?


totallytech

Recommended Posts

Hey Guys,

 

I'm trying to run some code to say if the string "ims_image" is found do this.... else do that...

 

I'm trying this:

 

<?php
$current = $_SERVER['REQUEST_URI'];
$mystring = 'ims_image';
$pos = strpos($mystring, $current);
echo "Search For " . $mystring . " within " . $current . "..... " . $pos;

if ($pos !== false) { ?>
       echo '<div class="sidebar1">';
       get_sidebar('gallery-left');
       echo '</div>';
} else { }     
?> 

 

Currently its failing - the echo output should say: Search For ims_image within /demo/ims_image/iwp-12-15-0011..... then either true or false but its blank.... just says Search For ims_image within /demo/ims_image/iwp-12-15-0011.....

 

Am I using the wrong method of searching the string?

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.