{"id":26776902,"url":"https://github.com/chiragobhan/php-arrays","last_synced_at":"2025-10-04T00:55:19.229Z","repository":{"id":216042143,"uuid":"265843115","full_name":"chiragobhan/php-arrays","owner":"chiragobhan","description":"Sort an array of temperatures in ascending order and retrieve 5 coolest and 5 warmest temperatures.","archived":false,"fork":false,"pushed_at":"2020-05-21T13:12:58.000Z","size":2,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-28T06:41:44.184Z","etag":null,"topics":["arrays","arraysort","php","retrieve-data","sorting","temperature"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chiragobhan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2020-05-21T12:29:22.000Z","updated_at":"2020-05-21T13:16:16.000Z","dependencies_parsed_at":"2024-01-08T07:06:43.314Z","dependency_job_id":null,"html_url":"https://github.com/chiragobhan/php-arrays","commit_stats":null,"previous_names":["chiragobhan/php-arrays"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/chiragobhan/php-arrays","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chiragobhan%2Fphp-arrays","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chiragobhan%2Fphp-arrays/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chiragobhan%2Fphp-arrays/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chiragobhan%2Fphp-arrays/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chiragobhan","download_url":"https://codeload.github.com/chiragobhan/php-arrays/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chiragobhan%2Fphp-arrays/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278250087,"owners_count":25955840,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-03T02:00:06.070Z","response_time":53,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["arrays","arraysort","php","retrieve-data","sorting","temperature"],"created_at":"2025-03-29T04:37:09.484Z","updated_at":"2025-10-04T00:55:19.210Z","avatar_url":"https://github.com/chiragobhan.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PHP Arrays\nSort an array of temperatures in ascending order and retrieve 5 coolest and 5 warmest temperatures.\n  \n### Initialize array\n`$array = array(68, 70, 72, 58, 60, 79, 82, 73, 75, 77, 73, 58, 63, 79, 78, 68, 72, 73, 80, 79, 68, 72, 75, 77, 73, 78, 82, 85, 89, 83);`  \n  \n### Print array\n`print_r($array);`  \n  \n#### Output:  \n![printArray](https://user-images.githubusercontent.com/32812640/82562015-0a62d080-9b92-11ea-8490-95c4582b636c.PNG)  \n  \n### Sort array in ascending order\n\u003cpre\u003e\nfor ($j = 0; $j \u003c count($array); $j++) {\n  for ($i = 0; $i \u003c count($array) - 1; $i++) {\n    if ($array[$i] \u003e $array[$i + 1]) {\n      $temp = $array[$i + 1];\n      $array[$i + 1] = $array[$i];\n      $array[$i] = $temp;\n    }\n  }\n} \n\u003c/pre\u003e  \n  \n### Average of all tempratures\n\u003cpre\u003e\n$total = 0;\nforeach ($array as $key =\u003e $value) {\n  $total = $total + $value;\n}\necho ($total / count($array)) . ' is the average of the temperatures.';\n\u003c/pre\u003e  \n  \n#### Output:  \n![average](https://user-images.githubusercontent.com/32812640/82561574-3d589480-9b91-11ea-9c6c-ee15a22c8802.PNG)  \n  \n### Five coolest tempratures\n\u003cpre\u003e\n$max = count($array);  \nfor ($i = $max - 5; $i \u003c $max; $i++) {  \n  echo \"$array[$i]\u0026#8457; temperature\";  \n}\n\u003c/pre\u003e\n  \n#### Output:  \n![coolest](https://user-images.githubusercontent.com/32812640/82561782-958f9680-9b91-11ea-8389-11f4e350b07e.PNG)  \n\n  \n### Five warmest tempratures\n\u003cpre\u003e\nfor ($i = 0; $i \u003c 5; $i++) {  \n  echo \"$array[$i]\u0026#8457; temperature\";  \n}\n\u003c/pre\u003e\n  \n#### Output:  \n![warmest](https://user-images.githubusercontent.com/32812640/82561725-798bf500-9b91-11ea-8094-924e9d476215.PNG)  \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchiragobhan%2Fphp-arrays","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchiragobhan%2Fphp-arrays","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchiragobhan%2Fphp-arrays/lists"}