<?php

$data = <<<'EOD'
[email protected]:Shaneez786 | Country = GB | Plan = Premium | Billing = 11 March 2022 | Payment = SKY_UK_IE_BILLED | Partner = Sky
[email protected]:Piddles11 | Country = US | Plan = Standard | Billing = October 28, 2023 | Payment = COMCAST | Partner = Xfinity | Phone = (413) 896-4576
[email protected]:Dog123bone! | Country = US | Plan = Standard | Billing = October 20, 2023 | Payment = CC | Phone = (724) 402-7487
[email protected]:Hotsummer18! | Country = US | Plan = Standard | Billing = October 24, 2023 | Payment = TMOBILE_US_BILLED | Partner = T-Mobile | Phone = (319) 400-1715
[email protected]:Lorenzo66 | Country = US | Plan = Standard | Ads = True | Billing = November 3, 2023 | Payment = CC | Phone = (434) 477-3730
[email protected]:3Kakisco! | Country = CA | Plan = Premium | Billing = January 26, 2023 | Payment = TELUS_INT_BILLED | Partner = TELUS | Phone = (604) 831-5256
[email protected]:London123! | Country = US | Plan = Standard | Billing = October 26, 2023 | Payment = ITUNES | Partner = Apple | Phone = (912) 247-1734
[email protected]:Basement1! | Country = US | Plan = Premium | Billing = November 13, 2023 | Payment = COMCAST | Partner = Xfinity | Phone = (203) 623-8094
[email protected]:25Cal2023! | Country = US | Plan = Standard | Ads = True | Billing = October 21, 2023 | Payment = CC | Phone = (650) 242-2440
[email protected]:Jeanann13! | Country = US | Plan = Premium | Billing = October 16, 2023 | Payment = CC
[email protected]:Dezyre2001 | Country = US | Plan = Standard | Ads = True | Billing = November 7, 2023 | Payment = COMCAST | Partner = Xfinity
[email protected]:Cierra1984! | Country = US | Plan = Premium | Billing = 23 October 2023 | Payment = CC | Phone = (916) 730-6520
[email protected]:Mallow20 | Country = GB | Plan = Standard | Ads = True | Billing = 4 de noviembre de 2023 | Payment = CC | Phone = 07500 179532
[email protected]:Ms16478734 | Country = US | Plan = Premium | Billing = September 16, 2023 | Payment = TMOBILE_US_BILLED | Partner = T-Mobile | Phone = (346) 304-5588
[email protected]:Lacy2011 | Country = GB | Plan = Premium | Billing = 28 March 2021 | Payment = SKY_UK_IE_BILLED | Partner = Sky | Phone = 07380 344271
[email protected]:MasonThunder4 | Country = US | Plan = Premium | Billing = October 22, 2023 | Payment = CC | Phone = (937) 710-6572
[email protected]:Mykierra1! | Country = US | Plan = Premium | Billing = May 10, 2023 | Payment = TMOBILE_US_BILLED | Partner = T-Mobile
[email protected]:emerald67 | Country = GB | Plan = Premium | Billing = 5 April 2022 | Payment = SKY_UK_IE_BILLED | Partner = Sky | Phone = 07950 358430
[email protected]:1jessica1 | Country = GB | Plan = Premium | Billing = 6 de septiembre de 2023 | Payment = SKY_UK_IE_BILLED | Partner = Sky | Phone = 07789 713922
[email protected]:Lenid57330! | Country = CA | Plan = Standard | Ads = True | Billing = 9 novembre 2023 | Payment = CC | Phone = (438) 408-2710
[email protected]:Spirit5843! | Country = US | Plan = Standard | Ads = True | Billing = October 19, 2023 | Payment = CC | Phone = (832) 443-0964
[email protected]:Sam1ullah | Country = GB | Plan = Premium | Billing = 22 October 2023 | Payment = CC
[email protected]:Corabarker11! | Country = GB | Plan = Premium | Billing = 10 December 2020 | Payment = SKY_UK_IE_BILLED | Partner = Sky | Phone = 07525 536986
[email protected]:Bcga1241! | Country = GB | Plan = Standard | Billing = 01 May 2023 | Payment = ASTRO__MEASAT_N_BILLED | Partner = Astro | Phone = 07398 755685
[email protected]:makoto910 | Country = JP | Plan = Standard | Billing = 2021/04/18 | Payment = KDDI_BILLED | Partner = au | Phone = 080-9828-1084
[email protected]:Eggtime1! | Country = GB | Plan = Standard | Billing = 26 October 2023 | Phone = 0870 320 3646
[email protected]:Papa1947 | Country = CA | Plan = Standard | Billing = October 21, 2023 | Payment = CC | Phone = (506) 721-6567
[email protected]:Pistons1 | Country = US | Plan = Premium | Billing = November 23, 2018 | Payment = COMCAST_BILLED | Partner = Xfinity
[email protected]:bigbird2458 | Country = GB | Plan = Standard | Billing = 17 October 2023 | Payment = SKY_UK_IE_BILLED | Partner = Sky
[email protected]:Mike1020 | Country = US | Plan = Premium | Billing = November 8, 2023 | Payment = COMCAST | Partner = Xfinity | Phone = (804) 721-0544
[email protected]:Lazarus27* | Country = US | Plan = Premium | Billing = December 27, 2018 | Payment = COMCAST_BILLED | Partner = Xfinity | Phone = (302) 632-3014
[email protected]:Tasneem95! | Country = CA | Plan = Premium | Billing = November 7, 2023 | Payment = CC | Phone = (647) 822-5050
[email protected]:10bear31 | Country = US | Plan = Standard | Billing = January 17, 2020 | Payment = TMOBILE_US_BILLED | Partner = T-Mobile
[email protected]:Bubzar123! | Country = GB | Plan = Standard | Ads = True | Billing = 08 November 2023 | Payment = PAYPAL | Phone = 07737 620267
[email protected]:Gabbylee123! | Country = US | Plan = Standard | Billing = October 28, 2023 | Payment = CC | Phone = (803) 804-4176
[email protected]:Timerly10! | Country = US | Plan = Standard | Billing = November 25, 2019 | Payment = TMOBILE_US_BILLED | Partner = T-Mobile | Phone = (801) 949-5355
[email protected]:Chesley0522! | Country = US | Plan = Standard | Billing = November 9, 2023 | Payment = CC | Phone = (801) 682-3634
[email protected]:Buffers1! | Country = US | Plan = Standard | Ads = True | Billing = November 8, 2023 | Payment = CC | Phone = (763) 267-9099
[email protected]:Msu2005 | Country = US | Plan = Standard | Ads = True | Billing = November 11, 2023 | Payment = CC | Phone = (810) 845-0415
[email protected]:All1991k! | Country = US | Plan = Standard | Ads = True | Billing = October 31, 2023 | Payment = CC | Phone = (262) 808-6010
[email protected]:Roberson1997 | Country = US | Plan = Standard | Ads = True | Billing = November 3, 2023 | Payment = PAYPAL | Phone = (601) 761-0568
[email protected]:Dannya01 | Country = GB | Plan = Premium | Billing = 19 August 2021 | Payment = SKY_UK_IE_BILLED | Partner = Sky | Phone = 07903 848236
[email protected]:Jaycp0408 | Country = GB | Plan = Standard | Billing = 02 November 2023 | Payment = CC | Phone = 07783 858048
[email protected]:Calister9! | Country = CA | Plan = Standard | Billing = June 7, 2022 | Payment = TELUS_INT_BILLED | Partner = TELUS
[email protected]:Milo1234 | Country = GB | Plan = Premium | Billing = 21 September 2019 | Payment = SKY_UK_IE_BILLED | Partner = Sky
[email protected]:Muffin1046 | Country = GB | Plan = Standard | Billing = 05 June 2023 | Payment = VIRGIN_MEDIA_BILLED | Partner = Virgin Media | Phone = 07770 993556
[email protected]:Taylor0512! | Country = US | Plan = Standard | Billing = November 13, 2023 | Payment = ITUNES | Partner = Apple | Phone = (254) 722-8662
[email protected]:Flippo1979! | Country = US | Plan = Premium | Billing = October 13, 2022 | Payment = TMOBILE_US_BILLED | Partner = T-Mobile
[email protected]:7Birdie7 | Country = US | Plan = Premium | Billing = October 16, 2023 | Payment = CC
[email protected]:Lola2016! | Country = GB | Plan = Premium | Billing = 23 July 2021 | Payment = SKY_UK_IE_BILLED | Partner = Sky
EOD;

$lines = explode("\n", $data);

$formatCountry = '/Country\s*[:=]\s*([A-Z]+)/';
$formatPhoneNumber = '/Phone\s*[:=]\s*([\d\s()+-]+)/';
$formatPlan = '/\bPlan\s*[:=]\s*([^\|]+)/';

$standards = "";
$premiums = "";

foreach ($lines as $line) {
    $emailPasswordSegments = explode(' | ', $line);
    $emailPassword = explode(':', $emailPasswordSegments[0]);
    $email = $emailPassword[0];
    $password = $emailPassword[1];

    $country = "";
    $phone = "";
    $plan = "";

    if (preg_match($formatCountry, $line, $matches)) {
        $country = $matches[1];
    }

    if (preg_match($formatPhoneNumber, $line, $matches)) {
        $phone = $matches[1];
    }
    
    if (preg_match($formatPlan, $line, $matches)) {
        $plan = trim($matches[1]);
    }
    
    if($country === 'GB') {
      $country = 'UK';
    }
    
    $result = !empty($phone) ? "$phone:$password | Country: $country \n" : "$email:$password | Country: $country\n";
    
    if($plan === 'Standard') {
      $standards .= $result;
    } elseif ($plan === 'Premium') {
      $premiums .= $result;
    }
    
}

echo "Standards:\n" . $standards . "\n\n";
echo "Premiums:\n" . $premiums;
?> 
by

PHP Online Compiler

Write, Run & Share PHP code online using OneCompiler's PHP online compiler for free. It's one of the robust, feature-rich online compilers for PHP language, running on the latest version 7. Getting started with the OneCompiler's PHP compiler is simple and pretty fast. The editor shows sample boilerplate code when you choose language as PHP and start coding.

Taking inputs (stdin)

OneCompiler's PHP online editor supports stdin and users can give inputs to programs using the STDIN textbox under the I/O tab. Following is a sample PHP program which takes name as input and prints hello message with your name.

<?php
	fscanf(STDIN, "%s\n", $name);           
    echo "Hello ".$name.".\n";
?>

About PHP

PHP(Hypertext Preprocessor) is widely used server sripting language by Rasmus Lerdorf in the year 1994.

Key features

  • Free
  • powerful tool for making dynamic and interactive web pages
  • can integrate with almost all popular databases like MySQL, PostgreSQL, Oracle, Sybase, Informix, Microsoft SQL Server etc.
  • C like Syntax and easy to learn.
  • Object oriented scripting language.
  • easily embeddable into HTML
  • Loosely typed language.

Syntax help

Variables

In PHP, there is no need to explicitly declare variables to reserve memory space. When you assign a value to a variable, declaration happens automatically. Variables are case-sensitive in PHP.

$variable_name = value;  

Loops

1. IF Family:

If, If-else, Nested-Ifs are used when you want to perform a certain set of operations based on conditional expressions.

If

if(conditional-expression){    
//code    
} 

If-else

if(conditional-expression){  
//code if condition is true  
} else {  
//code if condition is false  
} 

Nested-If-else

if(condition-expression1) {  
    //code if above condition is true  
} elseif(condition-expression2){  
    //code if above condition is true  
}  
elseif(condition-expression3) {  
    //code if above condition is true  
}  
...  
else {  
    //code if all the conditions are false  
}  

2. Switch:

Switch is used to execute one set of statement from multiple conditions.

switch(conditional-expression) {    
case value1:    
 // code if the above value is matched    
 break;  // optional  
case value2:    
 // code if the above value is matched    
 break;  // optional  
...    
    
default:     
 // code to be executed when all the above cases are not matched;    
} 
 

3. For:

For loop is used to iterate a set of statements based on a condition.

for(Initialization; Condition; Increment/decrement){  
  // code  
} 

For-each:

// you can use any of the below syntax
foreach ($array as $element-value) {  
    //code  
}

foreach ($array as $key => $element-value) {   
    //code 
} 

4. While:

While is also used to iterate a set of statements based on a condition. Usually while is preferred when number of iterations are not known in advance.

while(condition) {  
 // code 
}  

5. Do-While:

Do-while is also used to iterate a set of statements based on a condition. It is mostly used when you need to execute the statements atleast once.

do {
  // code 
} while (condition); 

Functions

Function is a sub-routine which contains set of statements. Usually functions are written when multiple calls are required to same set of statements which increases re-usuability and modularity.

How to define a Function

function function_name(parameters) {  
  //code
}

How to call a Function

function_name (parameters)