Skip to content

Commit f14cdf1

Browse files
added sample depicting usage
1 parent 695df09 commit f14cdf1

2 files changed

Lines changed: 26 additions & 2 deletions

File tree

CountryArray.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ public static function get( $keyField = 'a2', $requestedField = 'name' ){
290290

291291
$result = array();
292292
//copy each requested field from the countries array
293-
foreach( SELF::$countries as $k => $country ){
293+
foreach( self::$countries as $k => $country ){
294294
if( $keyField ){
295295
$result[ $country[ $keyField ] ] = $country[ $requestedField ];
296296
}else{
@@ -328,7 +328,7 @@ public static function get2d( $keyField = 'a2', $requestedFields = array( 'a2',
328328
}
329329
$result = array();
330330
//copy each requested field from the countries array
331-
foreach( SELF::$countries as $k => $country ){
331+
foreach( self::$countries as $k => $country ){
332332
$tmp = array( );
333333
foreach( $requestedFields as $field ){
334334
$tmp[ $field ] = $country[ $field ];

sample/sample1.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
/**
3+
* Created by PhpStorm.
4+
* User: sam
5+
* Date: 12/15/14
6+
* Time: 8:50 PM
7+
*/
8+
include( "../CountryArray.php" );
9+
10+
11+
$countries = CountryArray::get();
12+
var_dump( $countries );
13+
14+
15+
$countries = CountryArray::get2d( 'a3' );
16+
var_dump( $countries );
17+
18+
19+
$countries = CountryArray::get2d( 'a3', array( 'name', 'isd', 'continent' ) );
20+
var_dump( $countries );
21+
22+
23+
$countries = CountryArray::get2d( null, array( 'name', 'n', 'isd', 'continent' ) );
24+
var_dump( $countries );

0 commit comments

Comments
 (0)