<?php
/**
* для вопроса http://h...content-available-to-author-only...e.ru/questions/354054
*/
'custom' => 'name1:::::val1;;;;;name2:::::val2;;;;;name3:::::val3',
);
$cursor = 0;
$isKey = TRUE; // true for Key, false for Value
$pos = 0;
while( TRUE) {
$pos = mb_strpos( $custom['custom'], ($isKey ?
':::::' : ';;;;;'), $cursor); if( FALSE == $pos) {
if( $isKey) break;
else if( $cursor < $limit) $pos = $limit;
}
$sub = substr( $custom['custom'], $cursor, $pos - $cursor); if( $isKey) {
$key = $sub;
} else {
$custom[ $key] = $sub;
}
$isKey = !$isKey;
$cursor = $pos + 5; // 5 == length of separator
if( $cursor >= $limit) break;
}
PD9waHAKLyoqCiAqINC00LvRjyDQstC+0L/RgNC+0YHQsCBodHRwOi8vaC4uLmNvbnRlbnQtYXZhaWxhYmxlLXRvLWF1dGhvci1vbmx5Li4uZS5ydS9xdWVzdGlvbnMvMzU0MDU0CiAqLwokY3VzdG9tID0gYXJyYXkoCgknY3VzdG9tJyA9PiAnbmFtZTE6Ojo6OnZhbDE7Ozs7O25hbWUyOjo6Ojp2YWwyOzs7OztuYW1lMzo6Ojo6dmFsMycsCik7CgoKCiAgICAkY3Vyc29yID0gMDsKICAgICRpc0tleSA9IFRSVUU7IC8vIHRydWUgZm9yIEtleSwgZmFsc2UgZm9yIFZhbHVlCiAgICAkcG9zID0gMDsKICAgICRsaW1pdCA9IG1iX3N0cmxlbiggJGN1c3RvbVsnY3VzdG9tJ10pOwogICAgCiAgICB3aGlsZSggVFJVRSkgewogICAgCSRwb3MgPSBtYl9zdHJwb3MoICRjdXN0b21bJ2N1c3RvbSddLCAoJGlzS2V5ID8gJzo6Ojo6JyA6ICc7Ozs7OycpLCAkY3Vyc29yKTsKICAgIAlpZiggRkFMU0UgPT0gJHBvcykgewoJICAgIAlpZiggJGlzS2V5KSBicmVhazsKCSAgICAJZWxzZSBpZiggJGN1cnNvciA8ICRsaW1pdCkgJHBvcyA9ICRsaW1pdDsKICAgIAl9CiAgICAJCgkJ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