2021-01-15 07:20:11

Related Docs

Do You Need Help or Expertise?

Is editing Source Code not Your Thing? Are you in a tight Time Schedule and need to deliver a fully scalable and safe solution fast to your Clients?

Maybe you want to incorporate the Software found on TukuToi unbranded and royalty free in your Clients Projects after customizing it as per your Projects requirements?

Or eventually you need some training on any WordPress Plugin, Theme or their creation and maintenance?

How ToGet all occurrences of substring

Get all occurrences of a string within a string

function tkt_get_contents($str, $startDelimiter, $endDelimiter) {
  $contents = array();
  $startDelimiterLength = strlen($startDelimiter);
  $endDelimiterLength = strlen($endDelimiter);
  $startFrom = $contentStart = $contentEnd = 0;
  while (false !== ($contentStart = strpos($str, $startDelimiter, $startFrom))) {
    $contentStart += $startDelimiterLength;
    $contentEnd = strpos($str, $endDelimiter, $contentStart);
    if (false === $contentEnd) {
    $contents[] = substr($str, $contentStart, $contentEnd - $contentStart);
    $startFrom = $contentEnd + $endDelimiterLength;

  return $contents;

Use it like so:

$string = 'any string with any repetitive html or else valid text content such as this example';
$start = '';
$end = '';
$matches_array = tkt_get_contents($string, '', '');

This will produce:

    [0] => with
    [1] => else