Home >Backend Development >PHP Tutorial >PHP's 10 integers, sort from small to large, and output the sorting results

PHP's 10 integers, sort from small to large, and output the sorting results

WBOY
WBOYOriginal
2016-07-28 08:26:173206browse

10 integers, sorted from small to large, output the sorting results

<code><span>$aray</span> = <span>array</span>(<span>5</span>,<span>4</span>,<span>3</span>,<span>2</span>,<span>6</span>,<span>7</span>,<span>9</span>,<span>8</span>,<span>1</span>,<span>10</span>);
 <span>for</span>(<span>$i</span>=<span>0</span>;<span>$i</span><count(<span>$aray</span>);<span>$i</span>++){
      <span>for</span>(<span>$j</span>=<span>$i</span>+<span>1</span>;<span>$j</span><count(<span>$aray</span>);<span>$j</span>++){
          <span>$a</span>=<span>$aray</span>[<span>$i</span>];
          <span>$b</span>=<span>$aray</span>[<span>$j</span>];
          <span>if</span>(<span>$a</span>><span>$b</span>){
            <span>$aray</span>[<span>$i</span>]=<span>$b</span>;
            <span>$aray</span>[<span>$j</span>]=<span>$a</span>;
          }

      }
 }
 <span>//输出排序好的</span><span>for</span>(<span>$k</span>=<span>0</span>;<span>$k</span><count(<span>$aray</span>);<span>$k</span>++){
    <span>echo</span><span>$aray</span>[<span>$k</span>].<span>','</span>;

  }
</code>
').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });

The above introduces the 10 integers in PHP, sorting them from small to large, and outputting the sorting results, including the content. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn