Advertisement
Guest User

Untitled

a guest
Mar 21st, 2015
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.88 KB | None | 0 0
  1. $stringim = "[ayrac1]elma[/ayrac1][ayrac2]armut[/ayrac2][ayrac1]muz[/ayrac1][ayrac2]kiraz[/ayrac2]";
  2.  
  3. $string_arr = ikiStringArasiniAl($stringim,"[ayrac1]","[/ayrac1]");
  4. foreach($string_arr as $string_val)
  5. {
  6.     echo $string_val." ";
  7. }
  8.  
  9.  
  10. function ikiStringArasiniAl($myStr, $startStr, $endStr)
  11. {
  12.     $myArr = explode($endStr,$myStr);
  13.  
  14.     foreach($myArr as $myVal)
  15.     {
  16.         $myVal = $myVal."[endOfString]";
  17.         $returnArr[] = BetweenStr($myVal,$startStr,'[endOfString]');
  18.     }
  19.    
  20.     return  $returnArr;
  21. }
  22.  
  23. function BetweenStr($InputString, $StartStr, $EndStr=0, $StartLoc=0) {
  24.     if (($StartLoc = strpos($InputString, $StartStr, $StartLoc)) === false) { return; }
  25.     $StartLoc += strlen($StartStr);
  26.     if (!$EndStr) { $EndStr = $StartStr; }
  27.     if (!$EndLoc = strpos($InputString, $EndStr, $StartLoc)) { return; }
  28.     return substr($InputString, $StartLoc, ($EndLoc-$StartLoc));
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement