Adamhumbug Posted September 13, 2023 Share Posted September 13, 2023 (edited) I have an array. Array ( [0] => Array ( [id] => 19 [section_id] => 4 [sectionName] => x [itemName] => Item 1 [GBP] => 0 [USD] => 0 [CAD] => 0 [EUR] => 0 [charge_by_id] => 1 [consumable] => 1 [cMIN] => 1 [cMAX] => 499 [cGBP] => 500 [cUSD] => 750 [cCAD] => 875 ) [1] => Array ( [id] => 19 [section_id] => 4 [sectionName] => x [itemName] => Item 1 [GBP] => 0 [USD] => 0 [CAD] => 0 [EUR] => 0 [charge_by_id] => 1 [consumable] => 2 [cMIN] => 500 [cMAX] => 999 [cGBP] => 1 [cUSD] => 1.5 [cCAD] => 1.75 ) [2] => Array ( [id] => 19 [section_id] => 4 [sectionName] => x [itemName] => Item 1 [GBP] => 0 [USD] => 0 [CAD] => 0 [EUR] => 0 [charge_by_id] => 1 [consumable] => 3 [cMIN] => 1000 [cMAX] => 1999 [cGBP] => 0.9 [cUSD] => 1.35 [cCAD] => 1.58 ) [3] => Array i will foreach through most of it to get the data such as cMIN and cMAX on their own lines. I need to get the item name out of this once, rather than once per line - the query means that the data will only be for one item so there is no chance that the item name will be different for any items in the array. I have been trying to access the array data with value='$rows[0][itemName]'> but i am getting array to string conversion issue. How do i get this out of the array without for eaching it? Edited September 13, 2023 by Adamhumbug Quote Link to comment Share on other sites More sharing options...
Solution requinix Posted September 13, 2023 Solution Share Posted September 13, 2023 "Simple" string interpolation only allows you to access a single level of an array. If you want multiple levels then use the "complex" syntax with braces: "value='{$rows[0]['itemName']}'>" 1 Quote Link to comment Share on other sites More sharing options...
Adamhumbug Posted September 13, 2023 Author Share Posted September 13, 2023 1 hour ago, requinix said: "Simple" string interpolation only allows you to access a single level of an array. If you want multiple levels then use the "complex" syntax with braces: "value='{$rows[0]['itemName']}'>" Thanks for that - perfect Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.