Disambiguation - PHP List
Archive - Originally posted on "The Horse's Mouth" - 2014-03-07 06:01:11 - Graham EllisPHP Lists, or PHPList?
1. Lists in PHP
A PHP "array" - as they're know - is really a linked list in computer science terms [plus an ordered map - another story!]
Let me explain - a linked list is a series of values, one after another held in a single collection, and referenced by a position number in that collection. And the data at each position can be handled / processed in a loop.
<?php
$team = array("rOwEnA","colin","reBECCA","Graham","lISa");
foreach ($team as $friend) {
$onmy = ucwords(strtolower($friend));
print ("I am writing to $onmy\n");
}
?>
produces:
I am writing to Rowena
I am writing to Colin
I am writing to Rebecca
I am writing to Graham
I am writing to Lisa
The list function lets you name each element of an array a a separate variable, so I could write:
<?php
$team = array("rOwEnA","colin","reBECCA","Graham","lISa");
list ($party,$paid,$starguest,$drinks,$food) = $team;
print ("The organiser is $party and the catering is by $food\n");
?>
produces:
The organiser is rOwEnA and the catering is by lISa
Such lists are particularly useful where you have read a line of data from a file of database, and each element of a line / record relates to a different attribute / propoerty - lots of parties perhaps in our example!
Happy to tell you a lot more about lists on our PHP Courses.
2. PHPlist software
phplist is a piece of open source campaign managing software - see [here]. Whilst I need to manage my mailing lists better, I'm afraid I know little about it. Ah - if only I had the time to learn to be more efficient, I would then have the time ...