What is the Equivalent of C#'s "List <String>" in PHP?

PHP does not have the concept of generic types.

You can use array():

PHP

 $arr = array();  
 $arr[0] = 'foo';

equivalent in C#

List<string> arr = new List<string>(); 
arr.Add("foo"); 

I guess that you can use a simple array:

$list = array('string1', 'string2', 'string3');

or

$list = array();
$list[] = 'string1';
$list[] = 'string2';
$list[] = 'string3';

etc.

Check http://www.php.net/manual/en/language.types.array.php for details.


Is it an array?

Yes, it is

A comma-separated string?

No, it isn't

Tags:

Php