Cooper94 Posted April 25, 2009 Share Posted April 25, 2009 <?php echo substr($info, 0, strpos('Location', 'Contact')); ?> I am trying to make it output what ever is in bettwen Location and Contact on the $info variable. If you see something wrong please I am up for any ideas! Also if there is a different way I can do this that would be great too! Thank You Link to comment https://forums.phpfreaks.com/topic/155582-substr-strpos/ Share on other sites More sharing options...
gffg4574fghsDSGDGKJYM Posted April 25, 2009 Share Posted April 25, 2009 Try that : <?php $test = "bla bla bla Location abcde Contact bla bla bla"; preg_match_all("/Location(.*?)Contact/", $test, $result); print_r($result); ?> Link to comment https://forums.phpfreaks.com/topic/155582-substr-strpos/#findComment-818794 Share on other sites More sharing options...
RussellReal Posted April 25, 2009 Share Posted April 25, 2009 <?php $content = substr($info,$a = (strpos($info,$b = 'Location') + strlen($b)),strpos($info,'Contact',$a) - $a); ?> Link to comment https://forums.phpfreaks.com/topic/155582-substr-strpos/#findComment-818795 Share on other sites More sharing options...
subter Posted April 25, 2009 Share Posted April 25, 2009 <?php $info = "Location:abc1234Contact"; echo substr($info, 8, -7); ?> Link to comment https://forums.phpfreaks.com/topic/155582-substr-strpos/#findComment-818797 Share on other sites More sharing options...
.josh Posted April 25, 2009 Share Posted April 25, 2009 <?php $info = "Location:abc1234Contact"; echo substr($info, 8, -7); ?> that would just return "L" ....not to mention that it assumes that you even know the position of stuff in the array to begin with... Link to comment https://forums.phpfreaks.com/topic/155582-substr-strpos/#findComment-818804 Share on other sites More sharing options...
Cooper94 Posted April 25, 2009 Author Share Posted April 25, 2009 <?php $content = substr($info,$a = (strpos($info,$b = 'Location') + strlen($b)),strpos($info,'Contact',$a) - $a); ?> This one works perfectly the only thing though is it mess's up my page css. Like the footer is off and yeah... Is there a way to fix this css problem? Say like is there an exit(substr); script? Thank You Link to comment https://forums.phpfreaks.com/topic/155582-substr-strpos/#findComment-819068 Share on other sites More sharing options...
RussellReal Posted April 25, 2009 Share Posted April 25, 2009 that does nothing to the css Link to comment https://forums.phpfreaks.com/topic/155582-substr-strpos/#findComment-819070 Share on other sites More sharing options...
.josh Posted April 25, 2009 Share Posted April 25, 2009 There's nothing being output in that php so it's impossible that that is the cause of your css problem. Look somewhere else. Link to comment https://forums.phpfreaks.com/topic/155582-substr-strpos/#findComment-819144 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.