totallytech Posted February 7, 2013 Share Posted February 7, 2013 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 https://forums.phpfreaks.com/topic/274182-basic-query-find-a-string-within-a-string/ Share on other sites More sharing options...
totallytech Posted February 7, 2013 Author Share Posted February 7, 2013 Ugh, scrub that... I was using it wrong! $pos = strpos($mystring, $current); should be $pos = strpos($current, $mystring); Link to comment https://forums.phpfreaks.com/topic/274182-basic-query-find-a-string-within-a-string/#findComment-1410873 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.