Category : arrays

I’m trying to figure how to create a function that returns a value in a multidimensional array based on its key, while looping though another multidimensional array. Example: Sample JSON API response that’s been converted to an array: Products array [225]=> array(10) { ["id"]=> int(1571) ["product"]=> string(11) "shirts" ["group"]=> array(1) { [0]=> int(1146) } } ..

Read more

This is my json in postman: [ { "amount_refunded": 1, "base_amount_refunded": 1, "base_discount_amount": 0, "base_discount_invoiced": 0, "base_discount_refunded": 0, "base_discount_tax_compensation_amount": 0, "base_discount_tax_compensation_invoiced": 0, "base_discount_tax_compensation_refunded": 0, "base_original_price": 1, "base_price": 1, "base_price_incl_tax": 1, "base_row_invoiced": 1, "base_row_total": 1, "base_row_total_incl_tax": 1, "base_tax_amount": 0, "base_tax_invoiced": 0, "base_tax_refunded": 0, "created_at": "2021-10-04 13:02:36", "discount_amount": 0, "discount_invoiced": 0, "discount_percent": 0, "discount_refunded": 0, "free_shipping": 0, ..

Read more

i’ve already trying array_key_exists(). But when it should return the expected result, lumen display error message that i need to use another php function instead of array_key_exists() like isset() or property_exists() as mentioned in this question title. $jsonData = "mydata.json"; $content = file_get_contents($jsonData); $unsortedData = json_decode($content, true); //convert array to object $object = (object) $unsortedData; ..

Read more

I have this php code as I am trying to execute a particular function in my php project, I code the implementation correct but I ran into a small problem. <?php echo ‘<script type="text/javascript">’; $data = array( ‘base’ => ‘USD’, ‘alter’ => ‘ETH’, ‘data’ => array() ); foreach ($cryptos as $row) { $sy = $row["symbol"]; ..

Read more