Created
June 14, 2011 12:12
-
-
Save Tyrael/1024786 to your computer and use it in GitHub Desktop.
associative arrays from php.net karma system
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$url = 'http://svn.php.net/viewvc/SVNROOT/global_avail?revision=HEAD&view=co'; | |
$file = file_get_contents($url); | |
$avail_lines = array(); | |
$pattern = '/^avail\|(.*?)\|(.*?)$/sm'; | |
$repos = array(); | |
$users = array(); | |
preg_match_all($pattern, $file, $avail_lines); | |
foreach($avail_lines[0] as $i => $line){ | |
$line_users = explode(',', $avail_lines[1][$i]); | |
$line_repos = explode(',', $avail_lines[2][$i]); | |
foreach($line_repos as $repo){ | |
if(!isset($repos[$repo])){ | |
$repos[$repo] = array(); | |
} | |
} | |
foreach($line_users as $user){ | |
foreach($line_repos as $repo){ | |
$repos[$repo][] = $user; | |
$users[$user][] = $repo; | |
} | |
} | |
} | |
var_dump($users); | |
var_dump($repos); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment