[PHP]Array Functions

개발관련/PHP 2012. 4. 20. 15:12 |

	
		Array Functions
	
	
	
"; // shifts first element out of an array // and returns it. $a = array_shift($numbers); echo "a:" . $a ."
"; print_r($numbers); echo "

"; // prepends an element to an array, // returns the element count. $b = array_unshift($numbers, 'first'); echo "b: ". $b ."
"; print_r($numbers); echo "

"; echo "
"; // pops last element out of an array // and returns it. $a = array_pop($numbers); echo "a: " . $a ."
"; print_r($numbers); echo "

"; // pushes an element onto the end of an array, // returns the element count. $b = array_push($numbers, 'last'); echo "b: ". $b ."
"; print_r($numbers); echo "

"; ?> Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 [5] => 6 ) 

a:1
Array ( [0] => 2 [1] => 3 [2] => 4 [3] => 5 [4] => 6 ) 

b: 6
Array ( [0] => first [1] => 2 [2] => 3 [3] => 4 [4] => 5 [5] => 6 ) 


a: 6
Array ( [0] => first [1] => 2 [2] => 3 [3] => 4 [4] => 5 ) 

b: 6
Array ( [0] => first [1] => 2 [2] => 3 [3] => 4 [4] => 5 [5] => last ) 


'개발관련 > PHP' 카테고리의 다른 글

[PHP]Class Example 3  (0) 2012.04.20
[PHP]Class Example 2  (0) 2012.04.20
[PHP]Class Example  (0) 2012.04.20
[PHP]Access Modifiers 2  (0) 2012.04.20
[PHP]Access Modifiers  (0) 2012.04.20
Posted by 파노카페
: