Got an array thats like this..
Array
(
[1] => Array
(
[0] => Order Number
[1] => Item 1 Colour
[2] => Buyer Name
[3] => Item 1 Name
[4] => Item 1 Variation
)
[2] => Array
(
[0] => Order Number
[1] => Item 1 Colour
[2] => Buyer Name
[3] => Item 1 Name
[4] => Item 1 Variation
[5] => Order Number
[6] => Item 2 Colour
[7] => Buyer Name
[8] => Item 2 Name
[9] => Item 2 Variation
)
[3] => Array
(
[0] => Order Number
[1] => Item 1 Colour
[2] => Buyer Name
[3] => Item 1 Name
[4] => Item 1 Variation
[5] => Order Number
[6] => Item 2 Colour
[7] => Buyer Name
[8] => Item 2 Name
[9] => Item 2 Variation
[10] => Order Number
[11] => Item 3 Colour
[12] => Buyer Name
[13] => Item 3 Name
[14] => Item 3 Variation
)
}
This is showing 3 dummy orders and in this example, the first order has 1 item, the second-order has 2 items and the 3rd order has 3 items. as you can see the more items added the array just gets longer for that item and the numbers always increase in a set number of blocks. ie the title for item one in order 2 in the example above is [3] then for item 2 it is [8] (so same as before plus 5) then in order example 3 its [3], [8] & [13] so basically always plus 5 from the prev number ref
So can there a way to echo a value plus 5 of the prev value and keep doing that at all
like
$item1title = $myarray[5];
$item2title = $item1title[+5];
$item3title = $item2title[+5];
echo $item1title;
echo $item2title;
echo $item2title;
Here's a quick example of how you could build your array in a more useful way. As mentioned in the comments, we create a main orders array. Inside that array, we have an entry for each order. Each of those orders is also an array, and contains the details of the order, and also the items. The items are contained in an array, with each item as an entry in the array. Each item is itself also an array, with the entries being the item details.
$orders = array(
array(
"orderNum" => 123,
"buyerId" => 111,
"items" => array(
array(
"id" => 321,
"name" => "Item One",
"color" => "red"
)
)
),
array(
"orderNum" => 456,
"buyerId" => 444,
"items" => array(
array(
"id" => 321,
"name" => "Item One",
"color" => "red"
),
array(
"id" => 356,
"name" => "Item Two",
"color" => "green"
)
)
),
array(
"orderNum" => 789,
"buyerId" => 765,
"items" => array(
array(
"id" => 321,
"name" => "Item One",
"color" => "red"
),
array(
"id" => 356,
"name" => "Item Two",
"color" => "green"
),
array(
"id" => 999,
"name" => "Item Three",
"color" => "blue"
)
)
)
);
And here is a quick example of how you could access the orders and items
foreach($orders as $order)
{
echo "Order number: " . $order["orderNum"] . "\r\n";
foreach($order["items"] as $item)
{
echo "Item Name: " . $item["name"] . "\r\n";
}
echo "\r\n";
}