3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function parsingUtm($utmStr, $utmName) { $start = strpos($utmStr, 'source') + strlen($utmName) + 1; if($utmName != 'content'){ $end = strpos($utmStr, 'utm', $start) - 1; } else { $end = strlen($utmStr); } return substr($utmStr, $start, $end); } $utmStr = 'http://vk.com/?utm_source=yandex&utm_medium=cpc&utm_campaign={campaign_id}&utm_content={ad_id}&utm_term={keyword}'; var_dump(parsingUtm($utmStr, 'content'));
based on dgDDI
Output for 5.3.22 - 7.3.0beta1
string(86) "andex&utm_medium=cpc&utm_campaign={campaign_id}&utm_content={ad_id}&utm_term={keyword}"