<?php

$data = <<<'EOD'
[email protected]:Pitsy2010 | Country = US | Plan = Premium | Billing = 14 de octubre de 2023 | Payment = ITUNES
[email protected]:Next2day! | Country = GB | Plan = Standard | Billing = 19 October 2023 | Payment = CC
[email protected]:Tijuana2 | Country = US | Plan = Standard | Partner = T-Mobile | Billing = 1 de agosto de 2023 | Payment = TMOBILE_US_BILLED
[email protected]:Sonya2410! | Country = US | Plan = Standard | Billing = October 1, 2023 | Payment = CC | Phone = (281) 299-9605
[email protected]:Ytsim172563! | Country = US | Plan = Standard | Billing = October 11, 2023 | Payment = CC
[email protected]:Cambo055 | Country = US | Plan = Standard | Billing = October 15, 2023 | Payment = PAYPAL
[email protected]:Bengals123 | Country = US | Plan = Standard | Billing = September 27, 2023 | Payment = CC | Phone = (937) 546-3133
[email protected]:Georgia10 | Country = GB | Plan = Premium | Billing = 01 October 2023 | Payment = CC | Phone = 07543 863819
[email protected]:Celticcfc1! | Country = GB | Plan = Premium | Partner = Sky | Billing = 6 June 2023 | Payment = SKY_UK_IE_BILLED | Phone = 07950 783981
[email protected]:Thatdude88! | Country = US | Plan = Standard | Billing = October 17, 2023 | Payment = CC | Phone = (770) 653-3405
[email protected]:Riders2013 | Country = CA | Plan = Standard | Billing = October 8, 2023 | Payment = CC | Phone = (306) 230-5460
[email protected]:R5k6jinh02 | Country = AU | Plan = Premium | Billing = 15 October 2023 | Payment = PAYPAL | Phone = 0448 858 210
[email protected]:Thirty1! | Country = US | Plan = Premium | Billing = October 24, 2023 | Payment = CC | Phone = (573) 795-4998
[email protected]:Tigger01 | Country = US | Plan = Premium | Billing = October 23, 2023 | Payment = CC | Phone = (860) 690-0442
[email protected]:Superman10 | Country = US | Plan = Premium | Billing = October 2, 2023 | Payment = CC
[email protected]:Keesha68 | Country = US | Plan = Standard | Partner = T-Mobile | Billing = November 30, 2022 | Payment = TMOBILE_US_BILLED
[email protected]:Spikes44! | Country = US | Plan = Premium | Billing = October 1, 2023 | Payment = CC | Phone = (501) 249-6617
[email protected]:Addison05! | Country = US | Plan = Standard | Billing = October 10, 2023 | Payment = PAYPAL | Phone = (662) 273-3020
[email protected]:Caro18022 | Country = US | Plan = Standard | Billing = 2023 Oktober 12 | Payment = CC | Phone = (908) 249-2393
[email protected]:Gunner12 | Country = GB | Plan = Standard | Billing = 11 October 2023 | Payment = CC | Phone = 07821 333292
[email protected]:Ola24816! | Country = US | Plan = Standard | Billing = September 27, 2023 | Payment = PAYPAL | Phone = (216) 712-5252
[email protected]:june2355 | Country = CA | Plan = Standard | Billing = September 27, 2023 | Payment = CC | Phone = (613) 827-5539
[email protected]:Mong00$e | Country = CA | Plan = Premium | Billing = September 29, 2023 | Payment = CC | Phone = (204) 712-6011
[email protected]:06Dgp346! | Country = US | Plan = Standard | Billing = October 2, 2023 | Payment = CC | Phone = (606) 356-8479
[email protected]:Dlewelly12! | Country = US | Plan = Premium | Billing = October 11, 2023 | Payment = CC | Phone = (910) 750-2000
[email protected]:Obvious1! | Country = GB | Plan = Standard | Billing = 07 October 2023 | Payment = CC | Phone = 07880 358293
[email protected]:Ilovetasha12 | Country = GB | Plan = Standard | Billing = 05 October 2023 | Payment = CC | Phone = 07549 915260
[email protected]:Sarajojo1! | Country = US | Plan = Standard | Billing = October 20, 2023 | Payment = CC | Phone = (513) 833-4571
[email protected]:Asielkny1234 | Country = US | Plan = Premium | Billing = October 16, 2023 | Payment = CC | Phone = (347) 387-0216
[email protected]:Jeziah2007 | Country = NZ | Plan = Premium | Billing = 1 October 2023 | Payment = CC | Phone = 0210 225 9111
[email protected]:Loveme2012 | Country = US | Plan = Standard | Billing = October 18, 2023 | Payment = CC
[email protected]:Nordique59 | Country = CA | Plan = Standard | Billing = 28 septembre 2023 | Payment = CC | Phone = (418) 473-3304
[email protected]:Yahzee12! | Country = AU | Plan = Standard | Billing = 10 October 2023 | Payment = CC | Phone = 0479 005 200
[email protected]:David1494 | Country = AU | Plan = Premium | Billing = September 30, 2023 | Payment = CC | Phone = 0469 716 155
[email protected]:Ethan001! | Country = US | Plan = Standard | Billing = October 26, 2023 | Payment = CC | Phone = (786) 797-1924
[email protected]:Xeratul22! | Country = US | Plan = Standard | Billing = October 16, 2023 | Payment = CC | Phone = (254) 998-0580
[email protected]:Wsd68034 | Country = US | Plan = Standard | Billing = October 17, 2023 | Payment = CC | Phone = (657) 227-6911
[email protected]:Godlyoncod4 | Country = US | Plan = Standard | Billing = October 12, 2023 | Payment = CC | Phone = (315) 219-0784
[email protected]:Aubrey16! | Country = US | Plan = Standard | Billing = October 11, 2023 | Payment = CC | Phone = (315) 708-7834
[email protected]:Anthony97 | Country = NZ | Plan = Standard | Billing = 29 September 2023 | Payment = CC | Phone = 0210 278 367
[email protected]:Cristina1998 | Country = US | Plan = Standard | Billing = October 6, 2023 | Payment = CC | Phone = 156 1802 3692
[email protected]:Claire29 | Country = CA | Plan = Standard | Billing = September 30, 2023 | Payment = CC | Phone = (613) 769-0654
[email protected]:Gizmo0113 | Country = US | Plan = Standard | Billing = October 13, 2023 | Payment = CC | Phone = (512) 771-8425
[email protected]:Wyrypie28! | Country = US | Plan = Premium | Billing = October 17, 2023 | Payment = CC | Phone = (970) 596-0209
[email protected]:Charlize5464 | Country = US | Plan = Standard | Billing = October 18, 2023 | Payment = CC | Phone = (805) 574-4822
[email protected]:Fireman3291 | Country = US | Plan = Premium | Billing = October 3, 2023 | Payment = CC | Phone = (219) 798-7533
[email protected]:redsox88! | Country = US | Plan = Premium | Billing = October 15, 2023 | Payment = CC | Phone = (612) 432-2719
[email protected]:Jarrett8 | Country = US | Plan = Standard | Billing = September 30, 2023 | Payment = CC | Phone = (845) 406-8877
[email protected]:03June20! | Country = US | Plan = Premium | Billing = October 1, 2023 | Payment = CC | Phone = (616) 268-8224
[email protected]:Raining2 | Country = CA | Plan = Standard | Billing = October 17, 2023 | Payment = CC | Phone = (705) 498-8054
[email protected]:Gabychi01 | Country = US | Plan = Standard | Billing = October 11, 2023 | Payment = CC | Phone = (915) 491-0101
[email protected]:Cooper09! | Country = GB | Plan = Standard | Billing = September 30, 2023 | Payment = CC | Phone = 07720 765292
[email protected]:Ayden723! | Country = US | Plan = Premium | Partner = T-Mobile | Billing = April 28, 2023 | Payment = TMOBILE_US_BILLED
[email protected]:Apovlova1! | Country = US | Plan = Standard | Billing = October 7, 2023 | Payment = CC
[email protected]:Chair123! | Country = US | Plan = Premium | Partner = T-Mobile | Billing = December 29, 2022 | Payment = TMOBILE_US_BILLED
[email protected]:2Alabama2 | Country = US | Plan = Premium | Billing = October 20, 2023 | Payment = PAYPAL | Phone = (334) 437-2194
[email protected]:Vkriv5h3 | Country = GB | Plan = Standard | Billing = 15 October 2023 | Payment = CC | Phone = 561125783
[email protected]:Allie1010 | Country = US | Plan = Standard | Billing = October 11, 2023 | Payment = CC | Phone = (574) 933-3243
[email protected]:Chevo0929 | Country = US | Plan = Premium | Billing = September 30, 2023 | Payment = CC
[email protected]:Iloveher1! | Country = US | Plan = Standard | Billing = October 13, 2023 | Payment = CC | Phone = (318) 542-0681
[email protected]:Responder11! | Country = US | Plan = Premium | Billing = October 3, 2023 | Payment = CC | Phone = (434) 517-1892
[email protected]:Latics01! | Country = GB | Plan = Standard | Billing = 07 October 2023 | Payment = CC | Phone = 07557 096964
[email protected]:Chivy100 | Country = US | Plan = Standard | Billing = October 14, 2023 | Payment = CC | Phone = (609) 435-6124
[email protected]:Curtis1962 | Country = GB | Plan = Standard | Billing = 22 October 2023 | Payment = CC
[email protected]:Cahill17 | Country = GB | Plan = Standard | Billing = 08 October 2023 | Payment = CC | Phone = 07949 965509
[email protected]:215Joyss | Country = US | Plan = Premium | Billing = October 3, 2023 | Payment = CC | Phone = (272) 235-9740
[email protected]:Kenshin1! | Country = CA | Plan = Standard | Billing = October 8, 2023 | Payment = CC | Phone = (204) 996-6884
[email protected]:451996Rd! | Country = US | Plan = Standard | Billing = October 10, 2023 | Payment = CC | Phone = (737) 420-1555
[email protected]:Fullhouse12 | Country = US | Plan = Premium | Billing = October 23, 2023 | Payment = CC | Phone = (732) 597-4073
[email protected]:Kelsey10 | Country = CA | Plan = Premium | Billing = October 6, 2023 | Payment = CC | Phone = (780) 720-1081
[email protected]:R3dwings | Country = US | Plan = Standard | Partner = T-Mobile | Billing = April 19, 2018 | Payment = TMOBILE_US_BILLED | Phone = (419) 215-1881
[email protected]:Diorchanel8 | Country = US | Plan = Standard | Billing = 22 octobre 2023 | Payment = CC | Phone = 07 67 40 10 01
[email protected]:Cortez060602 | Country = US | Plan = Standard | Billing = October 3, 2023 | Payment = CC | Phone = (559) 410-4728
[email protected]:Celtic1888 | Country = GB | Plan = Standard | Billing = 08 October 2023 | Payment = CC
[email protected]:7Blythcourt! | Country = GB | Plan = Standard | Billing = 12 October 2023 | Payment = CC | Phone = 07719 974277
[email protected]:Dcdc93274 | Country = US | Plan = Premium | Billing = October 3, 2023 | Payment = CC | Phone = (559) 303-7424
[email protected]:Spazdarx7! | Country = AU | Plan = Premium | Billing = 7 October 2023 | Payment = CC
[email protected]:Bear53836! | Country = US | Plan = Standard | Billing = October 6, 2023 | Payment = CC | Phone = (478) 365-6775
[email protected]:Desy0412! | Country = US | Plan = Premium | Billing = October 11, 2023 | Payment = CC | Phone = (601) 497-2858
[email protected]:Mischief51! | Country = GB | Plan = Premium | Billing = 30 September 2023 | Payment = CC
[email protected]:Claudia123. | Country = US | Plan = Premium | Partner = T-Mobile | Billing = September 16, 2023 | Payment = TMOBILE_US_BILLED | Phone = (786) 416-1728
[email protected]:Jamesdean13! | Country = US | Plan = Premium | Billing = October 19, 2023 | Payment = CC | Phone = (908) 489-0289
[email protected]:Axeldean15! | Country = US | Plan = Standard | Billing = September 29, 2023 | Payment = CC | Phone = (360) 523-4289
[email protected]:Agencia123 | Country = US | Plan = Premium | Billing = October 20, 2023 | Payment = CC | Phone = (916) 548-1857
[email protected]:Sasquatch123 | Country = AU | Plan = Premium | Billing = 24 October 2023 | Payment = CC | Phone = 0423 522 432
[email protected]:Imptrooper1! | Country = US | Plan = Standard | Billing = October 17, 2023 | Payment = CC | Phone = (816) 786-0559
[email protected]:Maku1962! | Country = GB | Plan = Premium | Billing = 21 October 2023 | Payment = CC | Phone = 07360 174137
[email protected]:Fito2706 | Country = US | Plan = Premium | Billing = October 5, 2023 | Payment = CC
[email protected]:Anne4171 | Country = AU | Plan = Standard | Billing = 22 October 2023 | Payment = CC | Phone = 0412 567 572
[email protected]:Texy12345 | Country = AU | Plan = Standard | Billing = 16 October 2023 | Payment = PAYPAL
[email protected]:2728Brat | Country = US | Plan = Standard | Billing = October 25, 2023 | Payment = CC | Phone = (336) 260-9096
[email protected]:Rangers54! | Country = GB | Plan = Premium | Billing = 01 October 2023 | Payment = CC | Phone = 07927 410629
[email protected]:Tinley35! | Country = US | Plan = Standard | Billing = October 20, 2023 | Payment = CC | Phone = (208) 716-1204
[email protected]:Rebelck7 | Country = US | Plan = Standard | Billing = October 25, 2023 | Payment = CC | Phone = (732) 500-5246
[email protected]:Yellow78 | Country = US | Plan = Standard | Billing = October 13, 2023 | Payment = CC
[email protected]:Weeble13! | Country = US | Plan = Standard | Billing = October 2, 2023 | Payment = CC
[email protected]:Daymond7! | Country = US | Plan = Standard | Billing = October 9, 2023 | Payment = CC | Phone = (417) 630-9663
[email protected]:Ben72pebbles! | Country = US | Plan = Standard | Billing = October 22, 2023 | Payment = CC | Phone = (269) 655-5891
[email protected]:D34th24ll! | Country = US | Plan = Standard | Billing = September 29, 2023 | Payment = CC | Phone = (517) 867-3899
[email protected]:Daniel13! | Country = US | Plan = Premium | Billing = October 4, 2023 | Payment = CC | Phone = (814) 418-7763
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)