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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.