Explain the value of the variable input is a string 1,2,3,4,5,6,7. How would you get the sum of the integers contained inside input?



Explain the value of the variable input is a string 1,2,3,4,5,6,7. How would you get the sum of the ..

Answer / Apoorv Katiyar

In PHP, you can use the `array_sum()` function to achieve this. First, convert the string to an array and then pass it to the `array_sum()` function: n```phpn$input = '1,2,3,4,5,6,7';n$arr = explode(',', $input);n$sum = array_sum($arr);n```

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More PHP Interview Questions

How to create a table to store files?

1 Answers  


How many ways we can pass the variable through the navigation between the pages?

7 Answers  


What can I do by cakePHP?

4 Answers  


How to get elements in reverse order of an array in php?

1 Answers  


can anyone explain about stored procedure,Triggers and transaction in php?

2 Answers  


When to use self over $this?

1 Answers  


What is cookie?

1 Answers  


Does mysql need php?

1 Answers  


Which is the best php framework for a beginner?

1 Answers  


What is framework? How it works? What is advantage?

1 Answers  


What is html used for?

1 Answers  


How to create a text file in PHP?

1 Answers  


Categories