3v4l.org

run code in 300+ PHP versions simultaneously
<?php $keywordsUrlsArray = array( 0 => array ( 'url' => 'https://www.example.pl/?test=19', 'keyword' => 'test', 'score1' => 100, 'score2' => 50, 'position' => 4 ), 1 => array ( 'url' => 'https://www.example.pl/?test=2', 'keyword' => 'test', 'score1' => 100, 'score2' => 50, 'position' => 1 ), 2 => array ( 'url' => 'https://www.example.pl/?test=3', 'keyword' => 'test', 'score1' => 100, 'score2' => 50, 'position' => 3 ), 3 => array ( 'url' => 'https://www.example.pl/other-site?test=3', 'keyword' => 'test', 'score1' => 100, 'score2' => 50, 'position' => 3 ) ); $res = array(); foreach ($keywordsUrlsArray as $urlResults) { //remove params from url $parsedUrl = parse_url($urlResults['url']); $parsedUrl = $parsedUrl['scheme'] . '://' . $parsedUrl['host'] . $parsedUrl['path']; $keyword = $urlResults['keyword']; if (array_key_exists($parsedUrl, $res)) { if (isset($res[$parsedUrl][$keyword])) { $res[$parsedUrl][$keyword]['urlCount'] += 1; $res[$parsedUrl][$keyword]['score1'] += $urlResults['score1']; $res[$parsedUrl][$keyword]['score2'] += $urlResults['score2']; $res[$parsedUrl][$keyword]['sumPosition'] += $urlResults['position']; $res[$parsedUrl][$keyword]['position'] = $res[$parsedUrl][$keyword]['sumPosition'] / $res[$parsedUrl][$keyword]['urlCount']; continue; } } $res[$parsedUrl][$keyword] = $urlResults; $res[$parsedUrl][$keyword]['url'] = $parsedUrl; $res[$parsedUrl][$keyword]['urlCount'] = 1; $res[$parsedUrl][$keyword]['sumPosition'] = $urlResults['position']; } var_dump($res);
Output for git.master, git.master_jit, rfc.property-hooks
array(2) { ["https://www.example.pl/"]=> array(1) { ["test"]=> array(7) { ["url"]=> string(23) "https://www.example.pl/" ["keyword"]=> string(4) "test" ["score1"]=> int(300) ["score2"]=> int(150) ["position"]=> float(2.6666666666666665) ["urlCount"]=> int(3) ["sumPosition"]=> int(8) } } ["https://www.example.pl/other-site"]=> array(1) { ["test"]=> array(7) { ["url"]=> string(33) "https://www.example.pl/other-site" ["keyword"]=> string(4) "test" ["score1"]=> int(100) ["score2"]=> int(50) ["position"]=> int(3) ["urlCount"]=> int(1) ["sumPosition"]=> int(3) } } }

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
26.77 ms | 407 KiB | 5 Q