Class02 More Arrays MIS 3502, Spring 2016 Jeremy Shafer Department of MIS Fox School of Business Temple University 1/14/2016
Our progress… New tools Weeks 1-6 Using a web framework Weeks 7-9 Using a mobile device IDE Weeks The class project (It’s a bake off!) Weeks Arrays 2.PDO 3.MVC 4.JavaScript / JSON 5.RWD / CSS We’re here…
Objectives Last time … 1.Know what an array is. 2.Be able to create an array in PHP 3.Add, change, and delete data from an array. Today … 1.Associative Arrays 2.How to loop through arrays 3.Queues and Stacks 4.Sorting Arrays 5.Multidimensional Arrays
Associative Arrays You can see that the differences in syntax between working with associative arrays, and a numerically indexed arrays are pretty minor. Instead of: array(value1,valule2,value3, …)
Using a “for” loop The PHP function count() will return the number of elements in an array. That can be handy for controlling a “for” loop like this one.
Using a “foreach” loop.
Queues and Stacks
What’s a queue? A queue is a “First in, First Out” collection of values
What’s a stack? A stack is a “Last in, First Out” collection of values With stacks, we sometimes talk about “push” and “pop” operations.
Sorting an array These three functions are the most useful.
Multidimensional Arrays
The “times table” we just built…
One more handy function…
Let’s try an exercise P ERMANENT LINK TO THIS COMIC : HTTP :// XKCD. COM /1623/