Win a copy of Transfer Learning for Natural Language Processing (MEAP) this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Paul Clapham
  • Devaka Cooray
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Knute Snortum
  • Liutauras Vilda
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Piet Souris
Bartenders:
  • salvin francis
  • Carey Brown
  • Frits Walraven

str_split values in array

 
Ranch Hand
Posts: 106
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there .

i have this


and i get

Array ( [0] => 0 ) Array ( [0] => 0 ) Array ( [0] => 1 [1] => 0 ) Array ( [0] => 8 ) Array ( [0] => 0 ) Array ( [0] => 0 ) Array ( [0] => 1 [1] => 8 ) Array ( [0] => 8 )

this is what i have on the page .
how can i add the values of every cell.
example
Array ( [0] => 0 ) here i have 1 value but i want [0]=>something and one [1]=something so i want something + something=something;

Array ( [0] => 0 ) the same if its only one value no problem take the value and use it in a variable

Array ( [0] => 1 [1] => 0 ) here i have 2 values one in [0]=>1 and one [1]=0 so i want to have 1+0 =1;

Array ( [0] => 8 )

Array ( [0] => 0 )

Array ( [0] => 0 )

Array ( [0] => 1 [1] => 8 ) here i have 2 values one in [0]=>1 and one [1]=9 so i want to have 1+8 =9;

Array ( [0] => 8 )
after all i want to have them in a variable;

Remember that i have them through print_r ($temp0=str_split($temp2,1)); and this is the only way to have them.


thanks
 
Georgios Chatziefstratiou
Ranch Hand
Posts: 106
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have it .
 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Georgios Chatziefstratiou wrote:I have it .


Instead of such a quote, you could post (or explain) your solution. That might help others with a similar problem.
 
Georgios Chatziefstratiou
Ranch Hand
Posts: 106
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Roel De Nijs wrote:

Georgios Chatziefstratiou wrote:I have it .


Instead of such a quote, you could post (or explain) your solution. That might help others with a similar problem.



ok here you have it .I Change a little the code and it works fine. Bye



 
Bartender
Posts: 3648
16
Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Practically all PHP arrays can be iterated using the list() and each() methods to get the keys and/or values of each element.
 
Georgios Chatziefstratiou
Ranch Hand
Posts: 106
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

K. Tsang wrote:Practically all PHP arrays can be iterated using the list() and each() methods to get the keys and/or values of each element.


ok give an example if you want
 
I'm a lumberjack and I'm okay, I sleep all night and work all day. Lumberjack ad:
Two software engineers solve most of the world's problems in one K&R sized book
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic