Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

str_split values in array

 
Georgios Chatziefstratiou
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 .
 
Roel De Nijs
Sheriff
Posts: 9835
103
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • 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



 
K. Tsang
Bartender
Posts: 3348
12
Android 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic