3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $variations = array( 'Variation' => array( 'SKU' => 'ML328-8.42-21.329', 'StartPrice' => 29.95, 'Quantity' => 1, 'VariationSpecifics' => array( 'NameValueList' => array( 0 => array( 'Name' => 'Farbe', 'Value' => 'schwarz' ), 1 => array( 'Name' => 'Größe', 'Value' => 145, ) ) ), 'SellingStatus' => array( 'QuantitySold' => 0, 'QuantitySoldByPickupInStore' => 0, ) ) ); foreach ($variations['Variation'] as $nr => $v) { $extendedVariations[$nr] = array ( 'StartPrice' => $v['StartPrice'], 'Quantity' => $v['Quantity'] ); if ( (array_key_exists('SellingStatus', $v)) && (array_key_exists('QuantitySold', $v['SellingStatus'])) && ($v['SellingStatus']['QuantitySold'] > 0) ) { $extendedVariations[$nr]['Quantity'] -= $v['SellingStatus']['QuantitySold']; } }
based on rjXon
Output for 7.0.0 - 7.2.0
Warning: Illegal string offset 'StartPrice' in /in/9mHtj on line 29 Warning: Illegal string offset 'Quantity' in /in/9mHtj on line 30 Warning: array_key_exists() expects parameter 2 to be array, string given in /in/9mHtj on line 32 Warning: array_key_exists() expects parameter 2 to be array, float given in /in/9mHtj on line 32 Warning: array_key_exists() expects parameter 2 to be array, integer given in /in/9mHtj on line 32 Notice: Undefined index: StartPrice in /in/9mHtj on line 29 Notice: Undefined index: Quantity in /in/9mHtj on line 30 Notice: Undefined index: StartPrice in /in/9mHtj on line 29 Notice: Undefined index: Quantity in /in/9mHtj on line 30
Output for 5.4.0 - 5.6.28
Warning: Illegal string offset 'StartPrice' in /in/9mHtj on line 29 Warning: Illegal string offset 'Quantity' in /in/9mHtj on line 30 Warning: array_key_exists() expects parameter 2 to be array, string given in /in/9mHtj on line 32 Warning: array_key_exists() expects parameter 2 to be array, double given in /in/9mHtj on line 32 Warning: array_key_exists() expects parameter 2 to be array, integer given in /in/9mHtj on line 32 Notice: Undefined index: StartPrice in /in/9mHtj on line 29 Notice: Undefined index: Quantity in /in/9mHtj on line 30 Notice: Undefined index: StartPrice in /in/9mHtj on line 29 Notice: Undefined index: Quantity in /in/9mHtj on line 30
Output for 5.3.0 - 5.3.29
Warning: array_key_exists() expects parameter 2 to be array, string given in /in/9mHtj on line 32 Warning: array_key_exists() expects parameter 2 to be array, double given in /in/9mHtj on line 32 Warning: array_key_exists() expects parameter 2 to be array, integer given in /in/9mHtj on line 32 Notice: Undefined index: StartPrice in /in/9mHtj on line 29 Notice: Undefined index: Quantity in /in/9mHtj on line 30 Notice: Undefined index: StartPrice in /in/9mHtj on line 29 Notice: Undefined index: Quantity in /in/9mHtj on line 30
Output for 4.3.2 - 5.2.17
Warning: array_key_exists(): The second argument should be either an array or an object in /in/9mHtj on line 32 Warning: array_key_exists(): The second argument should be either an array or an object in /in/9mHtj on line 32 Warning: array_key_exists(): The second argument should be either an array or an object in /in/9mHtj on line 32 Notice: Undefined index: StartPrice in /in/9mHtj on line 29 Notice: Undefined index: Quantity in /in/9mHtj on line 30 Notice: Undefined index: StartPrice in /in/9mHtj on line 29 Notice: Undefined index: Quantity in /in/9mHtj on line 30
Output for 4.3.0 - 4.3.1
Warning: array_key_exists() [http://www.php.net/function.array-key-exists]: The second argument should be either an array or an object in /in/9mHtj on line 32 Warning: array_key_exists() [http://www.php.net/function.array-key-exists]: The second argument should be either an array or an object in /in/9mHtj on line 32 Warning: array_key_exists() [http://www.php.net/function.array-key-exists]: The second argument should be either an array or an object in /in/9mHtj on line 32 Notice: Undefined index: StartPrice in /in/9mHtj on line 29 Notice: Undefined index: Quantity in /in/9mHtj on line 30 Notice: Undefined index: StartPrice in /in/9mHtj on line 29 Notice: Undefined index: Quantity in /in/9mHtj on line 30