0

Suppose I have an array with 10 elements example: array(1,0,1,0,0,0,1,0,0,1)

How would I implement a function that replaces the values of an array using an if-else statement to evaluate the elements of the array. Say if the value is one, i would want to have an output of YES and if it is 0, then it is NO. Im sure i would be using a looping statement to evaluate each cells or element. Also, if one element has a value of 1.5 or any floating number, i would also want it to be replaced as YES.

Any tips would be greatly appreciated. Thanks in advance.

1 Answer 1

0

Just loop through the array and check for the element,

 if(!$arr[$i]) echo "NO"
 else echo "Yes"

You already have the idea, what exactly do you need?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.