コード例 #1
0
ファイル: 5_very_hard.php プロジェクト: jacobfoard/challenges
function val_sort($array, $key)
{
    //Loop through and get the values of our specified key
    foreach ($array as $k => $v) {
        $b[] = strtolower($v[$key]);
    }
    print_r($b);
    asort($b);
    echo '<br />';
    print_r($b);
    foreach ($b as $k => $v) {
        $c[] = $array[$k];
    }
    return $c;
}
$packagesArray = val_sort($packagesArray, 'price');
?>

<!DOCTYPE html>
<html>
  <head></head>
	<body>
      <h1>Packages</h1>
      <p>Here are all the packages we offer and their price:</p>
      <table>
        <th><td>Name</td><td>Price</td></th>
        <!-- 
          this for each loop will iterate over each item above and
          set $package as the inner array so we can have access to it directly
          this is appose to accessing them like so $packagesArray[0]['name'];
         -->
コード例 #2
0
ファイル: compare.php プロジェクト: picard102/CSV
}
// Combine arrays
//
$arr = array_merge($i2010c, $i2011c, $i2012c, $i2013c, $i2014c, $i2015c);
// Sort the merged array
function val_sort($array, $key)
{
    // Loop through and get the values of our specified key
    foreach ($array as $k => $v) {
        $b[] = strtolower($v[$key]);
    }
    asort($b);
    foreach ($b as $k => $v) {
        $c[] = $array[$k];
    }
    return $c;
}
// Sort by email (col 2)
$sorted = val_sort($arr, '2');
// Loop through files to QA file outputs
//
echo '<hr><table>';
foreach ($sorted as $unique_row) {
    echo '<tr>';
    foreach ($unique_row as $element) {
        echo '<td>' . $element . '</td>';
    }
    echo '</tr>';
}
echo '</table>';
echo '<br />';
コード例 #3
0
ファイル: array.php プロジェクト: akashsinha123/php-practice
	<?php 

	function val_sort($array, $key){
		foreach ($array as $k => $v) {
			$b[] = strtolower($v[$key]);
		}

		print_r($b);

		asort($b);

		echo "<br />";

		print_r($b);

		foreach ($b as $k => $v) {
			$c[] = $array[$k];
		}

		return $c;
	}

	$sorted = val_sort($course, "age");

	 ?>

	 <pre> <?php print_r($sorted) ?> </pre>

	
</body>
</html>