PhP Tutorial (3). Working with Arrays – Strings in PHP What is an Array.

Slides:



Advertisements
Similar presentations
Introduction to C Programming
Advertisements

Garfield AP Computer Science
CSE Lecture 3 – Algorithms I
Analysis of Algorithms
1 Various Methods of Populating Arrays Randomly generated integers.
Computer Science 112 Fundamentals of Programming II Bucket Sort: An O(N) Sort Algorithm.
Sorting Part 4 CS221 – 3/25/09. Sort Matrix NameWorst Time Complexity Average Time Complexity Best Time Complexity Worst Space (Auxiliary) Selection SortO(n^2)
HST 952 Computing for Biomedical Scientists Lecture 9.
Searching Kruse and Ryba Ch and 9.6. Problem: Search We are given a list of records. Each record has an associated key. Give efficient algorithm.
C++ Sets and Multisets Set containers automatically sort their elements automatically. Multisets allow duplication of elements whereas sets do not. Usually,
Sorting Algorithms. Motivation Example: Phone Book Searching Example: Phone Book Searching If the phone book was in random order, we would probably never.
Binary Search Visualization i j.
Arrays Liang, Chpt 5. arrays Fintan Array of chars For example, a String variable contains an array of characters: An array is a data structure.
Data Parallel Algorithms Presented By: M.Mohsin Butt
EGR 106 – Week 2 – Arrays Definition, size, and terminology Construction methods Addressing and sub-arrays Some useful functions for arrays Character arrays.
How should a computer shuffle?. Intro - 2 Comp 122, Goal  Input: Given n items to shuffle (cards, …)  Output: Return some list of exactly those n items;
CHAPTER 11 Searching. 2 Introduction Searching is the process of finding a target element among a group of items (the search pool), or determining that.
CSCI/CMPE 4341 Topic: Programming in Python Chapter 6: Lists, Tuples, and Dictionaries – Exercises Xiang Lian The University of Texas – Pan American Edinburg,
Guide to Programming with Python
Strings and Arrays. String Is a sequence of characters. Example: “hello”, “how are you?”, “123”,and are all valid string values.
INTERNET APPLICATION DEVELOPMENT For More visit:
Introduction to Internet Engineering Tutorial 7 All about Assignment 2 By Tse Hok
 2004 Prentice Hall, Inc. All rights reserved. 1 Chapter 11 - JavaScript: Arrays Outline 11.1 Introduction 11.2 Arrays 11.3 Declaring and Allocating Arrays.
Lists in Python.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 9 More About Strings.
CMPS 211 JavaScript Topic 2 Functions and Arrays.
Standard Algorithms –search for an item in an array –count items in an array –find the largest (or smallest) item in an array.
 2006 Pearson Education, Inc. All rights reserved Searching and Sorting.
Arrays Module 6. Objectives Nature and purpose of an array Using arrays in Java programs Methods with array parameter Methods that return an array Array.
Arrays The concept of arrays Using arrays Arrays as arguments Processing an arrays data Multidimensional arrays Sorting data in an array Searching with.
Object-Oriented Program Development Using Java: A Class-Centered Approach, Enhanced Edition.
Topic 25 - more array algorithms 1 "To excel in Java, or any computer language, you want to build skill in both the "large" and "small". By "large" I mean.
Introduction to PHP – Part 2 Sudeshna Dey. Arrays A series of homogeneous elements Elements have values in form of stored data Has a key associated with.
Web Database Programming Week 3 PHP (2). Functions Group related statements together to serve “a” specific purpose –Avoid duplicated code –Easy maintenance.
Min Chen School of Computer Science and Engineering Seoul National University Data Structure: Chapter 2.
Ch. 10 For Statement Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2012.
Collections behaviour and implementation of collections of primitives and objects.
Data Collections: Lists CSC 161: The Art of Programming Prof. Henry Kautz 11/2/2009.
An Introduction to STL. The C++ Standard Template Libraries  In 1990, Alex Stepanov and Meng Lee of Hewlett Packard Laboratories extended C++ with a.
Advanced Computer Science Lesson 4: Reviewing Loops and Arrays Reading User Input.
Project 1: Using Arrays and Manipulating Strings Essentials for Design JavaScript Level Two Michael Brooks.
1 CompSci 105 SS 2005 Principles of Computer Science Lecture 6: Recursion Lecturer: Santokh Singh Assignment 1 due tomorrow. Should have started working.
AP Computer Science edition Review 1 ArrayListsWhile loopsString MethodsMethodsErrors
CSE 232: C++ memory management Overview of Arrays Arrays are the simplest kind of data structure –One item right after another in memory (“contiguous range”
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter Arrays, Timers, and More 8.
Unit 12 JavaScript Arrays Instructor: Brent Presley.
 2008 Pearson Education, Inc. All rights reserved. 1 Arrays and Vectors.
IS2802 Introduction to Multimedia Applications for Business Lecture 4: JavaScript, Loops, and Conditional Statements Rob Gleasure
1. Searching The basic characteristics of any searching algorithm is that searching should be efficient, it should have less number of computations involved.
CSCI-256 Data Structures & Algorithm Analysis Lecture Note: Some slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved. 11.
 An array stores multiple values in one single variable.  Example: Output: I like Honda Civic, BMW and Toyota.
Visual C# 2005 Using Arrays. Visual C# Objectives Declare an array and assign values to array elements Initialize an array Use subscripts to access.
Variable Variables A variable variable has as its value the name of another variable without $ prefix E.g., if we have $addr, might have a statement $tmp.
VISUAL C++ PROGRAMMING: CONCEPTS AND PROJECTS Chapter 7A Arrays (Concepts)
PHP Tutorial. What is PHP PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages.
Lists/Dictionaries. What we are covering Data structure basics Lists Dictionaries Json.
LINKED LISTS.
Sorts, CompareTo Method and Strings
Chapter 6: Using Arrays.
Data Structures Recursion CIS265/506: Chapter 06 - Recursion.
Arrays An Array is an ordered collection of variables
CIS16 Application Development and Programming using Visual Basic.net
STL - Algorithms.
25 Searching and Sorting Many slides modified by Prof. L. Lilien (even many without an explicit message indicating an update). Slides added or modified.
CS2011 Introduction to Programming I Arrays (I)
24 Searching and Sorting.
Topics Basic String Operations String Slicing
Topics Basic String Operations String Slicing
Topics Basic String Operations String Slicing
Presentation transcript:

PhP Tutorial (3)

Working with Arrays – Strings in PHP What is an Array

Working with Arrays – Strings in PHP Creating Associative Arrays

Working with Arrays – Strings in PHP Creating Multidimensional Arrays

Working with Arrays – Strings in PHP Looping or Iterating Over Arrays

Working with Arrays – Strings in PHP Array Functions Reference list FunctionDescription array_change_key_case()Change all key case array_chunk()Returns a multidimensional array of the chunked array array_combine() Combine two arrays, one array becomes the keys and the other the values array_count_values()Count values in an array array_diff()Evaluate the difference in arrays array_fill_keys()Specify keys of an array as it gets values put into it array_fill()Fill an array with values specifying starting index and fill value array_filter()Filters elements array_flip()Swap all keys with their values array_intersect()Evaluate the intersection of arrays array_key_exists()Checks if the given key or index exists array_keys()List all keys

Working with Arrays – Strings in PHP Array Functions Reference list FunctionDescription array_merge_recursive()Recursively merge elements from two or more arrays array_merge()Merge the elements from one or more arrays array_multisort()Sort multiple arrays array_pad()Pad an array to match a given length array_pop()Pop the last element off the end array_product()Get the product of values array_push()Add to the end of an array array_rand()Get random items from an array array_reduce()Reduce the array to a single value array_replace_recursive()Replace array data recursively array_replace()Replace array data array_reverse()Reverse an array array_search()Returns the key of values searched for and found in an array

Working with Arrays – Strings in PHP Array Functions Reference list FunctionDescription array_shift()Remove the first element in an array and return the value array_slice()Remove a specified element of an array array_splice()Replace a specified element of an array array_sum()Evaluate the sum of values in an array array_unique()Removes duplicate values from an array array_unshift()Add elements to the beginning of an array array_values()Return all the values of an array array_walk_recursive()Run a function recursively on every item of an array array_walk()Run a function on every item of an array arsort()Sort an array in reverse and maintain index association asort()Sort an array and maintain index association compact()Uses variable names as keys and their values as array values count()Count elements in an array

Working with Arrays – Strings in PHP Array Functions Reference list FunctionDescription current()Return the current element each()Return the current key value pair end()Move the internal pointer to the last element in an array extract()Create PHP variables with values from an array in_array()Checks if a value exists in an array key()Get a key from an array krsort()Sort an array by key in reverse order ksort()Sort an array by key list()Create a list of variables from an array natcasesort()Sort an array using a case insensitive natural order algorithm natsort()Sort an array using a natural order algorithm next()Move the internal pointer of an array ahead pos()See current() prev()Move the internal pointer of an array backward

Working with Arrays – Strings in PHP Array Functions Reference list FunctionDescription range() Returns an array made up of a range of elements from an original array reset()Move the internal pointer of an array to the first element rsort()Sort an array in reverse order shuffle()Randomly shuffle an array sizeof()See count() sort()Sort an array uasort()Sort an array with a user defined comparison uksort()Sort an array by keys with a user defined comparison usort()Sort an array by values with a user defined comparison

Working with Arrays – Strings in PHP Working With Strings and Numbers What is the string?? A string is any one or set of alphanumeric characters and spaces. E.g. Validate Addresses With PHP preg_match() and a Regex

Working with Arrays – Strings in PHP Selected String Functions String FunctionDescription addcslashes()Adds slashes to a string in C style chunk_split()Returns a string split into chunks count_chars()Count occurances of a target character in a string explode()Splits a string and returns an array of the parts

Assignments Run All functions List for: – Array function list – String Function List – Math Function List