CCS0043 Module 3

0.0(0)
Studied by 0 people
call kaiCall Kai
Locked
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/61

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 1:40 AM on 7/18/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

62 Terms

1
New cards

Used to aggregate a series of similar items together, arranging and dereferencing them in some specific way

Array

2
New cards

Each member of the __ __ references a corresponding value and can be a simple numerical reference to the value's position in the series, or it could have some direct correlation to the value

array index

3
New cards

__ __ does not need to declare how many elements that the array variable have

PHP array

4
New cards

Array index in PHP can be also called as __ __

array keys

5
New cards

Array can be used as ordinary array same as in __ and __ arrays

C and C++ arrays

6
New cards

<?php

$fruit[0] = "orange";

$fruit[1] = "apple";

$fruit[2] = "grapes";

$fruit[3] = "banana";

echo "<pre>";

print_r($fruit);

echo "</pre>";

?>

Array

(

[0] => orange

[1] => apple

[2] => grapes

[3] => banana

)

7
New cards

<?php

$fruit[] = "orange";

$fruit[] = "apple";

$fruit[] = "grapes";

$fruit[] = "banana";

echo "<pre>";

print_r($fruit);

echo "</pre>";

?>

Array

(

[0] => orange

[1] => apple

[2] => grapes

[3] => banana

)

8
New cards

<?php

$fruit = array("orange", "apple", "grapes", "banana");

echo "<pre>";

print_r($fruit);

echo "</pre>";

?>

Array

(

[0] => orange

[1] => apple

[2] => grapes

[3] => banana

)

9
New cards

Short for print recursive

print_r() function

10
New cards

This takes an argument of any type and prints it out, which includes printing all its parts recursively

print_r() function

11
New cards

Same as the print_r function except that it prints additional information about the size and type of the values it discovers

var_dump() function

12
New cards

Functions are commonly used for debugging

print_r() and var_dump()

13
New cards

The point of this of these functions is to help you visualize what's going on with compound data structures like arrays

print_r() and var_dump()

14
New cards

<?php

$fruit = array(

"orange",

"apple",

"grapes",

"banana");

echo "<pre>";

print_r($fruit);

echo "</pre>";

?>

Array

(

[0] => orange

[1] => apple

[2] => grapes

[3] => banana

)

15
New cards

<?php

$fruit = array(

"orange",

"apple",

"grapes",

"banana");

echo "<pre>";

var_dump($fruit);

echo "</pre>";

?>

array(4) {

[0] =>

string(6) "orange"

[1] =>

string(5) "apple"

[2] =>

string(6) "grapes"

[3] =>

string(6) "banana"

}

16
New cards

A statement used to iterate or loop through the element in an array. With each loop, a foreach statement moves to the next element in an array.

foreach() function

17
New cards

Specify an array expression within a set of parenthesis following the foreach keyword

foreach statement

18
New cards

foreach($arr as $value) {

//do something with $value variable

}

foreach($arr as $key => $value) {

//do something with $key and/or $value variable

}

foreach() syntax

19
New cards

The name of the array that you're walking through

$arr

20
New cards

The name of the variable where you want to store the key (optional)

$key

21
New cards

The name of the variable where you want to store the value

$value

22
New cards

<?php

$fruit = array(

"orange",

"apple",

"grapes",

"banana",

"dragon fruit");

foreach($fruit as $value) {

echo "$value<br/>";

}

?>

orange

apple

grapes

banana

dragon fruit

23
New cards

Sorts by value; assign new numbers as the keys

sort($array)

24
New cards

Sorts by value in reverse order; assign new number as the keys

rsort($array)

25
New cards

Sorts by value; keeps the same key

asort($array)

26
New cards

Sorts by value in reverse order; keeps the same key

arsort($array)

27
New cards

Sorts by key

ksort($array)

28
New cards

Sorts by key in reverse order

krsort($array)

29
New cards

Sorts by a function

usort($array, functionname)

30
New cards

<?php

$fruit = array(

"orange", "apple",

"grapes", "banana",

"guava", "blueberry");

sort($fruit); //sort array in ascending

echo "<pre>";

print_r($fruit);

echo "</pre>";

rsort($fruit); //sort array in descending

echo "<pre>";

print_r($fruit);

echo "</pre>";

?>

Array

(

[0] => apple

[1] => banana

[2] => blueberry

[3] => grapes

[4] => guava

[5] => orange

)

Array

(

[0] => orange

[1] => guava

[2] => grapes

[3] => blueberry

[4] => banana

[5] => apple

)

31
New cards

<?php

$fruit = array(

"orange", "apple",

"grapes", "banana",

"guava", "blueberry");

asort($fruit);

echo "<pre>";

print_r($fruit);

echo "</pre>";

arsort($fruit);

echo "<pre>";

print_r($fruit);

echo "</pre>";

?>

Array

(

[1] => apple

[3] => banana

[5] => blueberry

[2] => grapes

[4] => guava

[0] => orange

)

Array

(

[0] => orange

[4] => guava

[2] => grapes

[5] => blueberry

[3] => banana

[1] => apple

)

32
New cards

<?php

$fruit = array(

'1010' => "orange",

'1002' => "apple",

'1023' => "grapes",

'1006' => "banana",

'1015' => "guava",

'1009' => "blueberry");

ksort($fruit);

echo "<pre>";

print_r($fruit);

echo "</pre>";

krsort($fruit);

echo "<pre>";

print_r($fruit);

echo "</pre>";

?>

Array

(

[1002] => apple

[1006] => banana

[1009] => blueberry

[1010] => orange

[1015] => guava

[1023] => grapes

)

Array

(

[1023] => grapes

[1015] => guava

[1010] => orange

[1009] => blueberry

[1006] => banana

[1002] => apple

)

33
New cards

A group of PHP statements that performs a specific task

Functions

34
New cards

Designed to allow you to reuse the same code in different locations

Functions

35
New cards

Functions that are provided by the user of the program

User Defined Functions

36
New cards

Functions that are built-in into PHP to perform some standard operations

Predefined Functions

37
New cards

Syntax (User Defined Functions):

function name(param) {

//code to be executed by the function

}

Where:

function - is the keyword used to declare a function

name - is the name of the function or function identifier

param - is the formal parameters of the function.

Parameter must follow the rule of naming identifiers

38
New cards

Declared outside a function and is available to all parts of the program

Global Variables

39
New cards

Declared inside a function and is only available within the function in which it is declared

Local Variables

40
New cards

Used to retain the values calls to the same function

Static Variables

41
New cards

Used to aggregate a series of similar items together

Array

42
New cards

Array index references a __ __

corresponding value

43
New cards

__ __ can be simple numerical or have some direct correlation to the value

Array index

44
New cards

Also known as Array Keys

Array index

45
New cards

Used to print the array structure

print_r function

46
New cards

The same as print_r function except it adds additional information about the data of each element

var_dump function

47
New cards

Used to iterate through the element in an array

foreach statement

48
New cards

Using __ __ you can display both the keys and value of each element in the array

foreach statement

49
New cards

PHP provides functions for array manipulation such as ______

sort(), rsort(), asort(), arsort(), ksort(), krsort(), and usort() functions

50
New cards

_________ functions are used to sort elements in the array in ascending order.

sort(), asort(), and ksort()

51
New cards

_________ functions are used to sort elements in the array in descending order

rsort(), arsort(), and krsort()

52
New cards

__ and __ does not maintain its index reference for each values

sort() and rsort()

53
New cards

__, __, __, and __ maintains its reference for each values

asort(), ksort(), arsort(), and krsort()

54
New cards

__ and __ used to sort elements by values

asort() and arsort()

55
New cards

__ and __ used to sort elements by keys

ksort() and krsort()

56
New cards

__ is a group of PHP statements that performs a specific task

Functions

57
New cards

Can be user defined generally defined by the user of the program and predefined that are build in using libraries

Functions

58
New cards

You use __ in different ways. __ can only do something without passing values. You can pass values to a __ and you can ask __ to return a value.

Function/s

59
New cards

Used in PHP to declare a function

function keyword

60
New cards

A function that is declared inside a function is said to be __

hidden

61
New cards

To gain access to a variable that is outside from the function we use the __ __

global keyword

62
New cards

We use __ __ to declare a variable inside a function that will act as accumulator variable this will let the program remember the last value of the variable that was used

static keyword