aspose file tools*
The moose likes PHP and the fly likes str_split  values in array Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Languages » PHP
Bookmark "str_split  values in array" Watch "str_split  values in array" New topic
Author

str_split values in array

Georgios Chatziefstratiou
Ranch Hand

Joined: May 26, 2012
Posts: 83
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

Joined: May 26, 2012
Posts: 83
I have it .
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5278
    
  13

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.


SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
http://www.javaroe.be/
Georgios Chatziefstratiou
Ranch Hand

Joined: May 26, 2012
Posts: 83
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

Joined: Sep 13, 2007
Posts: 2419
    
    7

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


K. Tsang JavaRanch SCJP5 SCJD/OCM-JD OCPJP7 OCPWCD5
Georgios Chatziefstratiou
Ranch Hand

Joined: May 26, 2012
Posts: 83
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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: str_split values in array