Skip to content

Instantly share code, notes, and snippets.

@farshid1
Created April 9, 2020 21:17
Show Gist options
  • Save farshid1/f818608a714b924e64a1c84b3a239bd8 to your computer and use it in GitHub Desktop.
Save farshid1/f818608a714b924e64a1c84b3a239bd8 to your computer and use it in GitHub Desktop.
<?php
$events = file_get_contents( 'https://someapi.com/events' );
$types = array();
foreach ( $events as $event ) {
$types[] = $event->type;
}
$score = 0;
foreach ( $types as $type ) {
switch ( $type ) {
case 'type1':
$score += 2;
break;
case 'type2':
$score += 5;
break;
case 'type3':
$score += 10;
break;
default:
$score += 1;
break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment