Hi! Could we please enable some services and cookies to improve your experience and our website?
Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code
<?php
$strarr = ["zone", "abigail", "theta", "form", "libe", "zas"];
$k = 2;
$str = '';
$sorted = array_map(fn($el)=> strlen($el), $strarr);
arsort($sorted);
$sorted = array_keys($sorted);
for($i=0;$i<$k;$i++){
$str .= $strarr[$sorted[$i]];
}
print_r($strarr[$sorted[0]]);