₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,327,267 members, 8,430,117 topics. Date: Friday, 19 June 2026 at 10:01 PM

Toggle theme

How Can I Add List Of Words From An API - Programming - Nairaland

Nairaland ForumScience/TechnologyProgrammingHow Can I Add List Of Words From An API (1168 Views)

1 Reply (Go Down)

How Can I Add List Of Words From An API by Nobody: 4:06pm On Feb 05, 2017
Good day programmers. I was working on a script lately php precisely. I'm working with an api. so I pulled out some numbers from the api. now I want to add them together how do I do that... example.. api gave strings as 428262848027. now I wan the machine to add 4+2+8+2+6+2+8.... note I tried to convert them to an array but they all have 0 as index numbers. pls help me
Re: How Can I Add List Of Words From An API by Nobody: 4:47pm On Feb 05, 2017
seunoni34:
Thank you!
can u help me here pls
Re: How Can I Add List Of Words From An API by seunoni34(m):
lankykid:
can u help me here pls
I didn't even know this was another post. Brb
Re: How Can I Add List Of Words From An API by FrankLampard: 5:37pm On Feb 05, 2017
http://php.net/manual/en/function.preg-split.php

Check this out, tell me when you need help.
Re: How Can I Add List Of Words From An API by seunoni34(m): 7:30pm On Feb 05, 2017
lankykid:
can u help me here pls
Assuming $string is the variable you want to split


$array = str_split($string); // this splits each character in $string to an array
/*

i.e if $string = 1234. The $array will look like

Array
(
[0] => 1
[1] => 2
[2] => 3
[3] => 4
)

*/

$sum = 0; // initialize variable that sums up all the numbers

// sum up the array of splitted numbers while looping

foreach($array as $num) :
$sum+=$num; // adds up all the numbers
endforeach;

echo $sum;
Re: How Can I Add List Of Words From An API by Nobody: 4:55pm On Feb 06, 2017
FrankLampard:
http://php.net/manual/en/function.preg-split.php

Check this out, tell me when you need help.
tanx a lot bro...
Re: How Can I Add List Of Words From An API by Nobody: 4:56pm On Feb 06, 2017
seunoni34:
Assuming $string is the variable you want to split


$array = str_split($string); // this splits each character in $string to an array
/*

i.e if $string = 1234. The $array will look like

Array
(
[0] => 1
[1] => 2
[2] => 3
[3] => 4
)

*/

$sum = 0; // initialize variable that sums up all the numbers

// sum up the array of splitted numbers while looping

foreach($array as $num) :
$sum+=$num; // adds up all the numbers
endforeach;

echo $sum;
Thanks a lot bro, this helped
1 Reply

How To Retrieve Data From An Api Using Fetch Api In JavascriptHelp With Calling An APII Need A Programmer To Design An API Scripts Library.234

Rapidpay Just Lunched Now, Make 200% Of Your MoneyASP.NET Tutorials For BeginnersFree Work Space For One Month At The Civic Innovation Lab, Abuja.