Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,174,309 members, 7,891,408 topics. Date: Tuesday, 16 July 2024 at 12:39 PM

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

Nairaland Forum / Science/Technology / Programming / How Can I Add List Of Words From An API (1053 Views)

How To Retrieve Data From An Api Using Fetch Api In Javascript / Help With Calling An API / I Need A Programmer To Design An API Scripts Library. (2) (3) (4)

(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): 4:48pm On Feb 05, 2017
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)

Hi Guys! Which I.T Course Can I Go For As A Beginner? / Functional E_commerce Websites..... Make Million Sales Instantly / Cali_coders

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 11
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.