<?php
function getMeat($foods) {
if (!isset($foods['meats'])) {
throw new Exception('There is no meat in this pie');
}
$meatCount = count($foods['meats']);
if($meatCount < 1) {
throw new Exception('Where did all the meat go!?');
}
var_dump($foods);
$i = 0;
$j = 1;
while($i < $meatCount)
{
if ($foods['meats'][$i] < $foods['meats'][$j]) {
$tempMeat = $foods['meats'][$i];
$foods['meats'][$i] = $foods['meats'][$j];
$foods['meats'][$j] = $tempMeat;
}
$i++;
$j++;
}
var_dump($foods);
}
$foods = array(
'meats' => array('zucci', 'burgers', 'steak', 'sausages', 'kebabs'),
'cake' => array('victorian', 'chocolate', 'fruit', 'fudge'),
);
getMeat($foods);
- Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
- array(2) {
["meats"]=>
array(5) {
[0]=>
string(5) "zucci"
[1]=>
string(7) "burgers"
[2]=>
string(5) "steak"
[3]=>
string(8) "sausages"
[4]=>
string(6) "kebabs"
}
["cake"]=>
array(4) {
[0]=>
string(9) "victorian"
[1]=>
string(9) "chocolate"
[2]=>
string(5) "fruit"
[3]=>
string(5) "fudge"
}
}
Warning: Undefined array key 5 in /in/s9kNh on line 23
array(2) {
["meats"]=>
array(5) {
[0]=>
string(5) "zucci"
[1]=>
string(5) "steak"
[2]=>
string(8) "sausages"
[3]=>
string(6) "kebabs"
[4]=>
string(7) "burgers"
}
["cake"]=>
array(4) {
[0]=>
string(9) "victorian"
[1]=>
string(9) "chocolate"
[2]=>
string(5) "fruit"
[3]=>
string(5) "fudge"
}
}
- Output for 5.5.0 - 5.5.35, 5.6.0 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.25, 7.4.27 - 7.4.33
- array(2) {
["meats"]=>
array(5) {
[0]=>
string(5) "zucci"
[1]=>
string(7) "burgers"
[2]=>
string(5) "steak"
[3]=>
string(8) "sausages"
[4]=>
string(6) "kebabs"
}
["cake"]=>
array(4) {
[0]=>
string(9) "victorian"
[1]=>
string(9) "chocolate"
[2]=>
string(5) "fruit"
[3]=>
string(5) "fudge"
}
}
Notice: Undefined offset: 5 in /in/s9kNh on line 23
array(2) {
["meats"]=>
array(5) {
[0]=>
string(5) "zucci"
[1]=>
string(5) "steak"
[2]=>
string(8) "sausages"
[3]=>
string(6) "kebabs"
[4]=>
string(7) "burgers"
}
["cake"]=>
array(4) {
[0]=>
string(9) "victorian"
[1]=>
string(9) "chocolate"
[2]=>
string(5) "fruit"
[3]=>
string(5) "fudge"
}
}
- Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 7.3.32 - 7.3.33, 7.4.26
- array(2) {
["meats"]=>
array(5) {
[0]=>
string(5) "zucci"
[1]=>
string(7) "burgers"
[2]=>
string(5) "steak"
[3]=>
string(8) "sausages"
[4]=>
string(6) "kebabs"
}
["cake"]=>
array(4) {
[0]=>
string(9) "victorian"
[1]=>
string(9) "chocolate"
[2]=>
string(5) "fruit"
[3]=>
string(5) "fudge"
}
}
array(2) {
["meats"]=>
array(5) {
[0]=>
string(5) "zucci"
[1]=>
string(5) "steak"
[2]=>
string(8) "sausages"
[3]=>
string(6) "kebabs"
[4]=>
string(7) "burgers"
}
["cake"]=>
array(4) {
[0]=>
string(9) "victorian"
[1]=>
string(9) "chocolate"
[2]=>
string(5) "fruit"
[3]=>
string(5) "fudge"
}
}
- Output for 4.4.2 - 4.4.9
- <br />
<b>Parse error</b>: syntax error, unexpected T_NEW in <b>/in/s9kNh</b> on line <b>7</b><br />
Process exited with code 255. - Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1
- <br />
<b>Parse error</b>: parse error, unexpected T_NEW in <b>/in/s9kNh</b> on line <b>7</b><br />
Process exited with code 255. - Output for 4.3.2 - 4.3.4
- <br />
<b>Parse error</b>: parse error in <b>/in/s9kNh</b> on line <b>7</b><br />
Process exited with code 255.
preferences:
233.91 ms | 401 KiB | 386 Q