Jump to content

Hello, I need to echo this out and I need them to say etc :

Elver 6,500,000 28-03-2017 21:05:00

 

How do I do this?

[0] => Array (
    [0] => Elver wired 6,500,000 Dollar. 28-03-2017 21:05:00
    [1] => Elver wired 6,500,000 Dollar. 28-03-2017 21:05:00
    [2] => Elver wired 6,500,000 Dollar. 28-03-2017 21:05:00
)
[1] => Array (
    [0] => Elver
    [1] => Elver
    [2] => Elver
)
[2] => Array (
    [0] => 6,500,000
    [1] => 6,500,000
    [2] => 6,500,000
)
[3] => Array (
    [0] => 28-03-2017 21:05:00
    [1] => 28-03-2017 21:05:00
    [2] => 28-03-2017 21:05:00
)

 

Back-end developer, electronics "hacker"

Link to comment
https://linustechtips.com/topic/759192-php-foreach-multidimensional-array/
Share on other sites

Link to post
Share on other sites

$array = array(
  array(
    'Elver wired 6,500,000 Dollar. 28-03-2017 21:05:00',
    'Elver wired 6,500,000 Dollar. 28-03-2017 21:05:00',
    'Elver wired 6,500,000 Dollar. 28-03-2017 21:05:00',
  ),
  array(
    'Elver',
    'Elver',
    'Elver',
  ),
  array(
    '6,500,000',
    '6,500,000',
    '6,500,000',
  ),
  array(
    '28-03-2017 21:05:00',
    '28-03-2017 21:05:00',
    '28-03-2017 21:05:00',
  ),
);

for($i = 0; $i < count($array[0]); $i++){
  echo $array[1][$i].' '.$array[2][$i].' '.$array[3][$i]; //You may want to add PHP_EOL or <br/> at the end of line.
}

I use first array to get count of elements then I just print one element of each array at given index.

Link to post
Share on other sites

Just now, Mr_KoKa said:

$array = array(
  array(
    'Elver wired 6,500,000 Dollar. 28-03-2017 21:05:00',
    'Elver wired 6,500,000 Dollar. 28-03-2017 21:05:00',
    'Elver wired 6,500,000 Dollar. 28-03-2017 21:05:00',
  ),
  array(
    'Elver',
    'Elver',
    'Elver',
  ),
  array(
    '6,500,000',
    '6,500,000',
    '6,500,000',
  ),
  array(
    '28-03-2017 21:05:00',
    '28-03-2017 21:05:00',
    '28-03-2017 21:05:00',
  ),
);

for($i = 0; $i < count($array[0]); $i++){
  echo $array[1][$i].' '.$array[2][$i].' '.$array[3][$i]; //You may want to add PHP_EOL or <br/> at the end of line.
}

I use first array to get count of elements then I just print one element of each array at given index.

Okey I see how you think, but I have no idea how to do that?

Back-end developer, electronics "hacker"

Link to post
Share on other sites

1 minute ago, Mr_KoKa said:

I'm confused. The $array is your array, the loop is exactly how you do this. I just made that array for the purpose of example, it is based on what you pasted.

Dafaq, Thanks! it looked exactly like the one I posted without anything at the end o.O

Back-end developer, electronics "hacker"

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×