What is diff. b/w array PUSH and POP? Explain with example?

Upgrade & Secure Your Future with DevOps, SRE, DevSecOps, MLOps!

We spend hours scrolling social media and waste money on things we forget, but won’t spend 30 minutes a day earning certifications that can change our lives.
Master in DevOps, SRE, DevSecOps & MLOps by DevOps School!

Learn from Guru Rajesh Kumar and double your salary in just one year.


Get Started Now!

The array_push() and array_pop() methods in PHP is used to perform insertions as well as deletions from the object. array_push is used to add value in the array(it always add new value at the last place) and array_pop is used to remove last value from the array.

syntax

array_push($array, $elements)   //array push
array_pop($array)      //array pop

example

<?php

		$color=array("red","green");
		
		array_push($color,"blue","yellow");
		
		  echo "<pre>";
		  
		print_r($color);
		
		 echo "</pre>";
		 
		 
		 echo "<br>";
		 echo "<br>";
		 
		
		$color=array("red","green","yellow","blue");
		
		array_pop($color);
		
		  echo "<pre>";
		  
		print_r($color);
		
		 echo "</pre>"; 
?>

output

Array
(
    [0] => red
    [1] => green
    [2] => blue
    [3] => yellow
)


Array
(
    [0] => red
    [1] => green
    [2] => yellow
)

Related Posts

The Certified MLOps Professional Path: A Definitive Guide for Modern Engineering Careers

Upgrade & Secure Your Future with DevOps, SRE, DevSecOps, MLOps! We spend hours scrolling social media and waste money on things we forget, but won’t spend 30…

Read More

Mastering the Certified MLOps Engineer Path: Skills, ROI, and Career Impact

Upgrade & Secure Your Future with DevOps, SRE, DevSecOps, MLOps! We spend hours scrolling social media and waste money on things we forget, but won’t spend 30…

Read More

Certified AIOps Professional: A Comprehensive Guide Value, Skills, and Career

Upgrade & Secure Your Future with DevOps, SRE, DevSecOps, MLOps! We spend hours scrolling social media and waste money on things we forget, but won’t spend 30…

Read More

The Professional Path to AIOps: A Deep Dive into the Certified AIOps Engineer

Upgrade & Secure Your Future with DevOps, SRE, DevSecOps, MLOps! We spend hours scrolling social media and waste money on things we forget, but won’t spend 30…

Read More

Master Modern Operations with the AIOps Foundation Certification

Upgrade & Secure Your Future with DevOps, SRE, DevSecOps, MLOps! We spend hours scrolling social media and waste money on things we forget, but won’t spend 30…

Read More

Certified Site Reliability Professional: Bridging the Gap Between Development and Operations

Upgrade & Secure Your Future with DevOps, SRE, DevSecOps, MLOps! We spend hours scrolling social media and waste money on things we forget, but won’t spend 30…

Read More
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x