Skip to content

Instantly share code, notes, and snippets.

@BigRedS
Created August 7, 2012 15:27
Show Gist options
  • Save BigRedS/3286376 to your computer and use it in GitHub Desktop.
Save BigRedS/3286376 to your computer and use it in GitHub Desktop.
Pro string handling in PHP
$perl = 'if($_ =~ /(\d+)\s*Ram,?\s*(\d+)\s*Cores,?\s*(\d+)%\s*CPU,?\s*(\d+)\s*GB\s*disk/i){ print "$1 $2 $3 $4";}';
$string = `echo $description | perl -ne '$perl'`;
list ($ram, $cores, $cpu, $disk) = explode(" ", $string);
$specs[$ram] = array(
'ram' => $ram,
'cores' => $cores,
'cpu' => $cpu,
'disk' => $disk,
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment