Jump to content

lol string position and copying

- - - - -

  • Please log in to reply
No replies to this topic

#1
brokenbylaw

brokenbylaw

    Learning Programmer

  • Members
  • PipPipPip
  • 62 posts
<?php
$string = "hello %this is text% hi";
$q1 = strpos($string, "%") + 1;
$q2 = strripos($string, "%");

echo mb_substr($string, $q1,$q2-$q1);
?>

it takes the string in between the %% and ignores everything else :)




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users