phptutorials

PHP Program to Separate Positive & Negative numbers from an Array

In this tutorial we are going to see how to separate positive & negative values from an array in PHP language.

The logic is very simple you have to loop through the array and check if the value is > 0 if yes then it is positive integer otherwise a negative integer and then just store the values in two different arrays.

Here is the snippet:

It’s very simple isn’t it?

I am also giving a demo script in this post so you can execute and see it:

Demo link:

demo

 

Related Posts

Leave a Reply