
{"id":6157,"date":"2011-10-25T12:56:59","date_gmt":"2011-10-25T12:56:59","guid":{"rendered":"http:\/\/www.beautifulwork.org\/?p=6157"},"modified":"2011-10-25T12:56:59","modified_gmt":"2011-10-25T12:56:59","slug":"bubble-sorting-using-php","status":"publish","type":"post","link":"https:\/\/www.trueangle.org\/index.php\/2011\/10\/25\/bubble-sorting-using-php\/","title":{"rendered":"bubble sorting using php"},"content":{"rendered":"<pre>\n&lt;?php\n\/* bubble.php by detour@metalshell.com\n *\n * Generate random numbers then sort them.\n *\n * http:\/\/www.metalshell.com\/\n *\n *\/\n\n\n$array_size = 250;\n\n\/\/ If you use v4.2.0 or lower uncomment this\n\/\/ srand((double)microtime()*1000000);\n\n\/\/ Generate $array_size random numbers to be sorted.\nfor($x = 0; $x &lt; $array_size; $x++)\n  $ran[$x] = rand(0, 500);\n\n\/* The bubble sort method.  If you don&#039;t know how it works it&#039;s very\n * simple, values are switched one at a time for each element. *\/\nfor($x = 0; $x &lt; $array_size; $x++) {\n  for($y = 0; $y &lt; $array_size; $y++) {\n    if($ran[$x] &lt; $ran[$y]) {\n      $hold = $ran[$x];\n      $ran[$x] = $ran[$y];\n      $ran[$y] = $hold;\n    }\n  }\n}\n\nfor($x = 0; $x &lt; $array_size; $x++)\n  print $ran[$x] . &quot;<br \/>\";\n\n\n?&gt;\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>&lt;?php \/* bubble.php by detour@metalshell.com * * Generate random numbers then sort them. * * http:\/\/www.metalshell.com\/ * *\/ $array_size = 250; \/\/ If you use v4.2.0 or lower uncomment this \/\/ srand((double)microtime()*1000000); \/\/ Generate $array_size random numbers to be sorted. for($x = 0; $x &lt; $array_size; $x++) $ran[$x] = rand(0, 500); \/* The bubble sort &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.trueangle.org\/index.php\/2011\/10\/25\/bubble-sorting-using-php\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;bubble sorting using php&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/posts\/6157"}],"collection":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/comments?post=6157"}],"version-history":[{"count":0,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/posts\/6157\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/media?parent=6157"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/categories?post=6157"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/tags?post=6157"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}