PHP – String Parser, Find a String Between Two Strings


function get_string_between($string, $start, $end){

$string = ” “. $string;

$ini = strpos($string,$start);

if ($ini == 0) return “”;

$ini += strlen($start);

$len = strpos($string, $end, $ini) – $ini;

return substr($string, $ini, $len);



echo get_string_between(“this is a test”, “this “, ” a test”); //RETURNS ‘is’

This is a very handy and easy to implement utility for PHP. Simply call the function as shown in order to get the string value between to known string points.

There are three variables that you need to pass to the function, the target text, the left data point and finally the right data point; in that order as well. The return of the function call is the string value that is between your two data points. It is important to note that the space character, ” ” counts as a valid character so keep that in mind or you’ll lose sleep over trying to figure out why it isn’t working only to realize that you didn’t account for a space somewhere!

The mechanics here are very simple. First, find the integer position of the the left point and then add that to the total length. Next find the integer position of the right data point starting at the integer position equal to the length of the left point and then subtract that by the total length of the left.

Lastly, return the original string starting at the end of the length of the left string point and ending at the beginning of the right string point.


Source link

472 thoughts on “PHP – String Parser, Find a String Between Two Strings

  1. Pingback: coolmath

  2. Pingback: Louis Vuitton Alma MM Roses M93686 louis vuitton shoes men

  3. Pingback: chaussures ugg

  4. Pingback: jHcbABbz

  5. Pingback: personality quiz

  6. Pingback: coolmath

  7. Pingback:

  8. Pingback: christian louboutin cyber monday

  9. Pingback: ocnGeyCC

  10. Pingback: iq test

  11. Pingback: beats by dre on sale black friday

  12. Pingback: black friday north face sale

  13. Pingback: Doudoune Moncler Quincy

  14. Pingback: Doudoune Pas Cher Moncler

  15. Pingback: Pull Moncler

  16. Pingback: Louis Vuitton Zippy Coin Purse M93740

  17. Pingback: coach cyber monday deals

  18. Pingback: louis vuitton thanksgiving sales

  19. Pingback: girls go games

  20. Pingback: best ecig

  21. Pingback: canada goose solaris parka

  22. Pingback: parka grand froid canada

  23. Pingback: ugg italia

  24. Pingback: billige canada goose

  25. Pingback: canada goose chilliwack femme occasion

  26. Pingback: canada goose a vendre

  27. Pingback: vente privée canada goose

  28. Pingback: ugg tilbud

  29. Pingback: casque de musique

  30. Pingback: chanel ¥Á¥§©`¥ó¥¦¥©¥ì¥Ã¥È

  31. Pingback: canada goose til salgs

  32. Pingback: canada goose avis

  33. Pingback: ugg norge nettbutikk

  34. Pingback: monster beat

  35. Pingback: casque beats solo hd

  36. Pingback: Billige Parajumpers

  37. Pingback: sport expert canada goose

  38. Pingback: uggs adirondack

  39. Pingback: snow mantra canada goose

  40. Pingback: ugg st酶vler k酶benhavn

  41. Pingback: moncler barn jacka

  42. Pingback: canada goose tatler

  43. Pingback: canada goose i norge

  44. Pingback: botte ugg

  45. Pingback: enceintes beats

  46. Pingback: woolrich outlet

  47. Pingback: canada goose outlet norge

  48. Pingback: uggs baby

  49. Pingback: dr dre casque

  50. Pingback: vente cordes canada goose

  51. Pingback: ugg norge nettbutikk

  52. Pingback: uggs st酶vler

  53. Pingback: ugg bamsest酶vler

  54. Pingback: canada goose doudoune manteaux hommes

  55. Pingback: uggs baby

  56. Pingback: ugg tilbud

  57. Pingback: haut parleur beats

  58. Pingback: moncler bonnet

  59. Pingback: beatsbydre pas cher

  60. Pingback: moncler grenoble

  61. Pingback: ugg bamsest酶vler

  62. Pingback: vente boutique en ligne canada goose

  63. Pingback: Parajumpers V氓rjakke

  64. Pingback: moncler bonnet

  65. Pingback: Billige moncler vest

  66. Pingback: Billige moncler udsalg

  67. Pingback: cable pour casque beats

  68. Pingback: tous les produits canada goose

  69. Pingback: casque dre

  70. Pingback: ugg votter

  71. Pingback: casque beats solo hd

  72. Pingback: casque beats by dre pas cher ebay

  73. Pingback: magasin canada goose neuilly

  74. Pingback: canada goose shop online

  75. Pingback: canada goose jakker pris

  76. Pingback: canada goose pas chère

  77. Pingback: beats by dre

  78. Pingback: casque beats by dre pas cher chine

  79. Pingback: canada goose langford parka

  80. Pingback: moncler dunvest

  81. Pingback: canada goose dunjakke

  82. Pingback: купить canada goose

  83. Pingback: canada goose magasin france

  84. Pingback: canada goose jakke dame

  85. Pingback: casque audio beats

  86. Pingback: Billige Parajumpers

  87. Pingback: prix d une canada goose

  88. Pingback: parka canada goose occasion

  89. Pingback: ugg pas cher enfant

  90. Pingback: canada goose expedition parka sale

  91. Pingback: timberland sko tilbud

  92. Pingback: canada goose chateau parka

  93. Pingback: canada goose banff parka

  94. Pingback: magasin canada goose montreal

  95. Pingback: canada goose retailer

  96. Pingback: canada goose tremblant jacket

  97. Pingback: billig moncler jacka stockholm

  98. Pingback: casque monster

  99. Pingback: canada goose taille s

  100. Pingback: canada goose doudoune homme

  101. Pingback: canada goose sale jackets

  102. Pingback: uggs norge salg

  103. Pingback: canadian goose

  104. Pingback: Parajumpers V氓rjakke

  105. Pingback: canada goose trillium parka

  106. Pingback: canada goose bomber jacket

  107. Pingback: parka canada goose homme pas cher

  108. Pingback: canada goose shop online

  109. Pingback: canada goose shop online

  110. Pingback: uggs kopior online

  111. Pingback: canda goose

  112. Pingback: Chanel UK

  113. Pingback: canada goose outlet ca

  114. Pingback: goose jacket

  115. Pingback: uggs cleaning

  116. Pingback: kensington parka canada goose

  117. Pingback: canada goose dun

  118. Pingback: canada goose parkas

  119. Pingback: parka store canada goose

  120. Pingback: canada goose vente privee

  121. Pingback: beats dre

  122. Pingback: Parajumpers V氓rjakke

  123. Pingback: canada goose billig

  124. Pingback: manteau canada goose pas cher

  125. Pingback: canada goose norge

  126. Pingback: canada goose outlet

  127. Pingback:

  128. Pingback: ugg

  129. Pingback: canada goose jakke menn

  130. Pingback: Billige Parajumpers

  131. Pingback: veste moncler homme

  132. Pingback: canada goose usa

  133. Pingback: canada goose kids

  134. Pingback: beats by dre fnac

  135. Pingback: canada goose expedition parka men

  136. Pingback: mode doudoune canada goose

  137. Pingback: canada goose jacket outlet

  138. Pingback: cheap canada goose

  139. Pingback: canada goose vest pris

  140. Pingback: parajumpers oslo

  141. Pingback: canada goose snow mantra

  142. Pingback: canada goose china

  143. Pingback: canada goose snow mantra

  144. Pingback: Parajumpers Norge

  145. Pingback: Parajumpers Norge

  146. Pingback: canada goose på nätet

  147. Pingback: Parajumpers V氓rjakke

  148. Pingback: canada goose parkas sale

  149. Pingback: manteau canada goose prix

  150. Pingback: acheter canada goose etats unis

  151. Pingback: chilliwack bomber canada goose

  152. Pingback: canada goose priser

  153. Pingback: canada goose jakke dame billig

  154. Pingback: blouson canada goose homme

  155. Pingback: doudoune homme canada goose pas cher

  156. Pingback: goose down jacket

  157. Pingback: prix canada goose femme

  158. Pingback: manteau canada goose prix

  159. Pingback: canada goose jackets 2010

  160. Pingback: canada goose parkas on sale

  161. Pingback: Parajumpers Jakker

  162. Pingback: canada goose constable parka

  163. Pingback: kodiak parajumpers

  164. Pingback: buy canadian goose

  165. Pingback: parajumpers kodiak herr

  166. Pingback: migration of canada geese of canada geese

  167. Pingback: billig canada goose expedition parka

  168. Pingback: Canada Goose Jacket Men

  169. Pingback: canada goose chateau parka

  170. Pingback: canada goose men

  171. Pingback: canada goose trillium parka

  172. Pingback: canada goose parkas

  173. Pingback: Canada Goose Winter Jacket Hybrid Style

  174. Pingback: canada goose sale online

  175. Pingback: ugg boots sale women

  176. Pingback: Canada Goose Women S Chilliwack Parka

  177. Pingback: parajumpers passport

  178. Pingback: canada goose jakker pris

  179. Pingback: canada goose paris citadium

  180. Pingback: parajumpers jacket

  181. Pingback: Canada Goose Warehouse Toronto

  182. Pingback: chanel paris

  183. Pingback: trillium parka canada goose montreal

  184. Pingback: canadian goose

  185. Pingback: original parka jacket

  186. Pingback: canada goose vest for sale

  187. Pingback: canada goose lady

  188. Pingback: Canada Goose Trillium Parka Sale

  189. Pingback: canada goose trillium parka norge

  190. Pingback: parajumpers kodiak woman

  191. Pingback: Canada Goose Mystique Down Parka

  192. Pingback: canada goose at calgary

  193. Pingback: Canada Goose Womens Trillium Parka

  194. Pingback: parajumper parkas

  195. Pingback: expedition parka

  196. Pingback: parka jacket womens white

  197. Pingback: norvegien parka

  198. Pingback: canada goose youth

  199. Pingback: Jacket In Halifax

  200. Pingback: купить canada goose

  201. Pingback: toronto

  202. Pingback: Goose Winter Jacket

  203. Pingback: price of a canada goose jacket

  204. Pingback: Parajumpers Salg

  205. Pingback: canada goose vancouver

  206. Pingback: Billige Parajumpers

  207. Pingback: canada goose men jacket

  208. Pingback: canada goose victoria parker xs

  209. Pingback: canada goose salg

  210. Pingback: Original Parka Kids

  211. Pingback: canada goose i oslo

  212. Pingback: Canada Goose Dunjacka

  213. Pingback: canada goose jacket sale on boxing day

  214. Pingback: kensington parka pris

  215. Pingback: canada ski bomber

  216. Pingback: which i warmer parajumpers or canada goose

  217. Pingback: canada goose chateux test

  218. Pingback: Louis Vuitton Outlet Online Store Authentic Handbags For Sale

  219. Pingback: mens parka ottawa

  220. Pingback: jacket outlet store winnipeg

  221. Pingback: canada goose oslo butikk

  222. Pingback: mens goose chateau parka size chart

  223. Pingback: Canada Goose Kids Sale

  224. Pingback: coat sales toronto

  225. Pingback: canada goose kopia

  226. Pingback: doudounes canada goose pas cher

  227. Pingback: chanel collection

  228. Pingback: winter bomber jacket montreal

  229. Pingback: harry rosen goose jacket

  230. Pingback: down jacket made in usa or canada

  231. Pingback: Canada Goose Goslings For Sale

  232. Pingback: Canada Goose Black Friday

  233. Pingback: kensington canada goose parka

  234. Pingback: canada goose cg 55 kensington parka where to buy

  235. Pingback: Louis Vuitton Outlet

  236. Pingback: Warmwinterparka.Com

  237. Pingback: canadian goose down expedition official outlet

  238. Pingback: Canada Goose Review

  239. Pingback: Mens Coats Clipart

  240. Pingback: canada goose dame

  241. Pingback: parajumper til barn

  242. Pingback: Canada Goose Retailer

  243. Pingback: greygoose jacket

  244. Pingback: Yorkville Bomber Jacket

  245. Pingback: canada goose discount

  246. Pingback: Chaussures Baskets pas cher

  247. Pingback: where to buy canada goose jackets for kids in winnipeg

  248. Pingback: canada goose ontario parka

  249. Pingback: snowgoose jackets

  250. Pingback: parajumper kodiak

  251. Pingback: north copenhagen parka

  252. Pingback: canada goose store las vegas

  253. Pingback: canada goose aviator hat sale

  254. Pingback: louis vuitton outlet store

  255. Pingback: mens canada goose ontario parka navy

  256. Pingback: god canada goose

  257. Pingback: Canada Goose Clothing Website

  258. Pingback: canada goose women mittens montreal

  259. Pingback: goose lodge jacket

  260. Pingback: kjøp parajumpers online

  261. Pingback: parajumpers til salgs

  262. Pingback: canada goose online montreal

  263. Pingback: canada goose heli arctic

  264. Pingback: White Canada Goose Jacket

  265. Pingback: yorkville parka vs chilliwack bomber

  266. Pingback: parajumpers jakke pris

  267. Pingback: canada goose artic programs

  268. Pingback: forhandler af parajumpers danmark

  269. Pingback: canada goose solaris

  270. Pingback: canada goose mens sergeant parka

  271. Pingback: top winter jacket canada

  272. Pingback: parajumper 58

  273. Pingback: canada goose billigt

  274. Pingback: there a louis vuitton outlet

  275. Pingback: Canada Goose Chateau Parka Men

  276. Pingback: Canada Goose Winter Jacket

  277. Pingback: Canada Goose Jackets For Kids In Montreal

  278. Pingback: Louis Vuitton

  279. Pingback: trillium canada goose summit pink

  280. Pingback: sale canada goose jackets

  281. Pingback: Canada Goose Lodge Vest

  282. Pingback: louis vuitton outlet

  283. Pingback: dove comprare canada goose expedition parka

  284. Pingback: parajumper denali women

  285. Pingback: canada goose outlet store winnipeg

  286. Pingback: sportchek montreal

  287. Pingback: Louis Vuitton Outlet Store

  288. Pingback: buy cheap louis vuitton

  289. Pingback: canada goose outlet vancouver

  290. Pingback: Women’S Pbi Chilliwack Bomber

  291. Pingback: cheap louis vuitton outlet

  292. Pingback: canada grey goose jacket price

  293. Pingback: louis vuitton bags cheap

  294. Pingback: discount canada goose parka

  295. Pingback: parajumpers kodiak dam

  296. Pingback: louis vuitton outlet

  297. Pingback: military green montebello

  298. Pingback: vintage louis vuitton handbags

  299. Pingback: canada goose kids vancouver

  300. Pingback: where can i buy canada goose parker coats in the u.k

  301. Pingback: louis vuitton outlet

  302. Pingback: the best parkas in montreal

  303. Pingback: official canada goose online sale

  304. Pingback: pink parka jacket

  305. Pingback: louis vuitton outlet

  306. Pingback: canadian winter parkas

  307. Pingback: canadian goose down clearance

  308. Pingback: canada goose ladies trillium parka sale

  309. Pingback: canada goose kensington tan

  310. Pingback: parkas canada goose

  311. Pingback: goose feather vest

  312. Pingback: canada goose jackets in edmonton

  313. Pingback: womens goose down winter coats

  314. Pingback: long bear parajumpers

  315. Pingback: canadangoose livigno parca

  316. Pingback: louis vuitton outlet

  317. Pingback: Do Canada Geese Migrate

  318. Pingback: canada goose wasaga sand trillium

  319. Pingback: louis vuitton outlet

  320. Pingback: louis vuitton outlet

  321. Pingback: Canada Goose Expedition Red

  322. Pingback: louis vuitton outlet

  323. Pingback: canada goose icicle vest white

  324. Pingback: canada goose pink vest xl

  325. Pingback: coach outlet

  326. Pingback: Winter Jackets In Sale In Toronto

  327. Pingback: Canada Goose Tremblant Jacket

  328. Pingback: Goose Jacket Canada

  329. Pingback: Canada Goose Coats Canada

  330. Pingback: juanjuan

  331. Pingback: special edition jackets canada goose

  332. Pingback: Canada Goose Stores In Montreal

  333. Pingback: Outlets Canada

  334. Pingback: buy canada goose online

  335. Pingback: Canada Goose Jacket Vancouver

  336. Pingback: Canada Goose Toronto Factory

  337. Pingback: shop for womens parka in montreal

  338. Pingback: chilliwack outlet toronto

  339. Pingback: louis vuitton outlet store

  340. Pingback: Canada Goose Chilliwack Noir

  341. Pingback: louis vuitton outlet

  342. Pingback: canada goose vs parajumper

  343. Pingback: Chilliwack Parka

  344. Pingback: winter jacket on sale at toronto

  345. Pingback: canadian goosedown montaineering duvet

  346. Pingback: Canada Goose Constable Down Parka Sale

  347. Pingback: louis vuitton outlet

  348. Pingback: Canada Goose Resolute Parka Vs Trillium Parka

  349. Pingback: Kejo Jakker

  350. Pingback: Canada Goose Outlet Calgary

  351. Pingback: kids canada goose down jackets

  352. Pingback: canada goose canada outlet

  353. Pingback: canadian red down arctic

  354. Pingback: where cani buy a canada goose jacket cheap

  355. Pingback: udsalg parajumpers

  356. Pingback: Goose Canada Jackets

  357. Pingback: モンクレール セザンヌ サイズ

  358. Pingback: canada goose astrila parka

  359. Pingback: Canada Goose Products

  360. Pingback: Canada Goose 3037L

  361. Pingback: Canada Goose Jacket Factory In Toronto

  362. Pingback: leather goose down vest

  363. Pingback: how many geese to make canada goose jacket

  364. Pingback: fake goose pas cher

  365. Pingback: louis vuitton outlet

  366. Pingback:

  367. Pingback:

  368. Pingback:

  369. Pingback: Oreo 5s 2013

  370. Pingback:

  371. Pingback:

  372. Pingback: canada goose

  373. Pingback: canada goose

  374. Pingback: billig Canada Goose

  375. Pingback:

  376. Pingback: Canada Goose Jacken

  377. Pingback: Canada Goose Parka

  378. Pingback: Canada Goose till salu

  379. Pingback: canada goose jacket

  380. Pingback:

  381. Pingback: Canada Goose onlinebutik

  382. Pingback: canada goose jakke

  383. Pingback: Canda goose black friday sale

  384. Pingback: Christian Louboutin Sale

  385. Pingback: Mulberry Handbags

  386. Pingback: Coach Factory Outlet Online

  387. Pingback:

  388. Pingback:

  389. Pingback: Canada Goose Outlet

  390. Pingback: Christian Louboutin

  391. Pingback: Canada Goose

  392. Pingback: Mulberry Outlet

  393. Pingback: Canada Goose Jakker

  394. Pingback: capretto Canada Goose

  395. Pingback: canada goose haute performance

  396. Pingback: Jackets Outlet

  397. Pingback:

  398. Pingback:

  399. Pingback:

  400. Pingback: canada goose jackets

  401. Pingback: Canada Goose Parka

  402. Pingback: canada goose

  403. Pingback: Canada Goose

  404. Pingback:

  405. Pingback:

  406. Pingback:

  407. Pingback:

  408. Pingback: canada goose online

  409. Pingback: Canada Goose

  410. Pingback:

  411. Pingback:

  412. Pingback: ロレックス ディープシー

  413. Pingback: free run 3.0 v3

  414. Pingback: louis vuitton 財布

  415. Pingback: loubiton maillot suede mary jane

  416. Pingback: ヴィトン 財布

  417. Pingback: dafodil christian louboutin 37 black patent

  418. Pingback: nike high

  419. Pingback: nouvelle air jordan

  420. Pingback: nike homme pas cher

  421. Pingback: ヴィトン 財布 メンズ

  422. Pingback: christian louboutin men sneakers for sale

  423. Pingback: ロレックス レプリカ

  424. Pingback: ビトン 財布

  425. Pingback: ロレックス

  426. Pingback: belt louis vuitton factory outlet

  427. Pingback: louis vuitton speedy 40 authentic

  428. Pingback: air max 90 femme

  429. Pingback: louboutin tutu suede stitch

  430. Pingback: basket nike fille

  431. Pingback: chaussures nike free 3.0 v3

  432. Pingback: ロレックス 中古

  433. Pingback: ヴィトン バッグ 人気

  434. Pingback: ロレックス エクスプローラー

  435. Pingback: ロレックス アンティーク

  436. Pingback: christian louboutin rollerboy

  437. Pingback: pas cher air max

  438. Pingback: ロレックス ミルガウス

  439. Pingback: デイトジャスト

  440. Pingback: oakley sunglasses employment 85202

  441. Pingback: oakley romeo glasses

  442. Pingback: Christian Louboutin Jenny

  443. Pingback: platform knee boot

  444. Pingback: ヴィトン リュック

  445. Pingback: ロレックス サブマリーナ

  446. Pingback: ヴィトン バック

  447. Pingback: ロレックス アンティーク

  448. Pingback: nike free 5.0 pas cher

  449. Pingback: louis vuitton monogramouflage treillis

  450. Pingback: vente sac louis vuitton occasion

  451. Pingback: ceinture louis vuitton damier

  452. Pingback: ys2GwioiJr

  453. Pingback: louis vuitton cuir epi

  454. Pingback: silver slingback pumps

  455. Pingback: christian louboutin red pumps uk outlets

  456. Pingback: ヴィトン画像

  457. Pingback:

  458. Pingback: sacs vuitton en ligne

  459. Pingback: oakley sunglasses fake jewelry

  460. Pingback: cheap designer louis vuitton handbags

  461. Pingback: louis vuitton wallets made in usa

  462. Pingback: nike shox moins cher

  463. Pingback: shoe nike

  464. Pingback: air max bw noir

  465. Pingback: nike collection

  466. Pingback: ロレックス レディース

  467. Pingback: air max 87

  468. Pingback: nike blazer vintage suede

  469. Pingback: cheap flat shoes

  470. Pingback: Christian Louboutin Morphea

  471. Pingback: ヴィトン ショルダーバッグ

  472. Pingback: requin nike

Comments are closed.