title: How to print a multidimensional array that the user selected?
body: <p>The 3 options are name, batting order, and position. The user must pick which option he/she would like the values to be sorted. Currently, it prints the sorted batting order value because that's the last sorting order before I called echo. How do I make it so when the user picks an option, only the output of that option shows? And no output when nothing is selected?</p>
  
  <p>Here is the HTML</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
      &lt;head&gt;
          &lt;link rel="stylesheet" type="text/css" href="Assignment.css"&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;main&gt;
              &lt;form action="Assignment1.php" method="post"&gt;
          &lt;h2&gt;Rays Lineup Display&lt;/h2&gt;
          &lt;div id="data"&gt;
  
              &lt;p&gt;Select Size&lt;/p&gt;
              &lt;input type="radio" name="order" value="player_name"&gt;Player Name&lt;br&gt;
              &lt;input type="radio" name="order" value="pos"&gt;Position&lt;br&gt;
              &lt;input type="radio" name="order" value="bats"&gt;Batting Order&lt;br&gt;
  
            &lt;/div&gt;
  
              &lt;div id="buttons"&gt;
                  &lt;label&gt;&amp;nbsp;&lt;/label&gt;
                  &lt;input type="submit" value="Submit"&gt;&lt;br&gt;
              &lt;/div&gt;
              &lt;/form&gt;
          &lt;/main&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>PHP File</p>
  
  <pre><code>    &lt;!DOCTYPE html&gt;
      &lt;html&gt;
          &lt;head&gt;
              &lt;link rel="stylesheet" type="text/css" href="Assignment.css"&gt;
          &lt;/head&gt;
          &lt;body&gt;                    
  
           &lt;?php
  
              $selection_list = array('pos', 'player_name', 'bats');
              $players = array (
              array('pos' =&gt; 'SS', 'player_name' =&gt; 'Beckham', 'bats' =&gt; 1),
              array('pos' =&gt; 'C', 'player_name' =&gt; 'Casali', 'bats' =&gt; 8),
              array('pos' =&gt; '2B', 'player_name' =&gt; 'Forsythe', 'bats' =&gt; 3),
              array('pos' =&gt; '1B', 'player_name' =&gt; 'Loney', 'bats' =&gt; 7),
              array('pos' =&gt; 'LF', 'player_name' =&gt; 'Jennings', 'bats' =&gt; 2),
              array('pos' =&gt; 'CF', 'player_name' =&gt; 'KierMaier', 'bats' =&gt; 9),
              array('pos' =&gt; '3B', 'player_name' =&gt; 'Longoria', 'bats' =&gt; 4),
              array('pos' =&gt; 'RF', 'player_name' =&gt; 'Mahtook', 'bats' =&gt; 5),
              array('pos' =&gt; 'DH', 'player_name' =&gt; 'Souza', 'bats' =&gt; 6),
              );
  
  
    function getSortFunction( $sortKey ) {
    return function( $personA, $personB ) use ( $sortKey ) {
      return ( $personA[$sortKey] &lt; $personB[$sortKey] ) ? -1 : 1;
    };
  }
  
  
  
   $order = filter_input(INPUT_POST,'order');
              usort( $players, getSortFunction( 'pos' ) );
              usort( $players, getSortFunction( 'player_name' ) );
               usort( $players, getSortFunction( 'bats' ) );
              echo '&lt;pre&gt;'; print_r($players); echo '&lt;pre/&gt;';
  ?&gt;
  
  &lt;/body&gt;
  </code></pre>
  
  <p></p>