Category

PHP Interview

Category

Sorting array value without using built in php like sort() etc Bubble sort in php <?php $array =array(‘2′,’4′,’8′,’5′,’1′,’7′,’6′,’9′,’10’,’3′); echo ‘Unsorted array’; print_r($array); for($i = 0; $i<count($array); $i++){ for($j = 0; $j <count($array)-1; $j++){ if($array[$j] > $array[$j+1]){ $temp = $array[$j+1]; $array[$j+1] = $array[$j]; $array[$j] = $temp; } } } echo ‘Sorted array’; print_r($array); ?> Reverse Order Sorting <?php $array = array(‘2′,’4′,’8′,’5′,’1′,’7′,’6′,’9′,’10’,’3′); echo ‘Unsorted array’; print_r($array); for($i = 0; $i<count($array); $i++){ for($j = 0; $j <count($array)-1; $j++){…

There are many differences between PHP 5 and 7. Some of the main points are: Performance: PHP 7: Performance speed is double. Average requests per second are 44 when it is 22 in php5. PHP 5: Performance is low compared to php7. Return Type: In PHP 5, the programmer is not allowed to define the type of return value of a function which is the major drawback. But in PHP 7, this limitation is overcome…

What are Implode and Explode functions? Ans: The implode() function returns a string from the elements of an array. It takes an array of strings and joins them together into one string using a delimiter (string to be used between the pieces) of your choice. The implode function in PHP is easily converting as “array to string”, which simply means that it takes an array and returns a string. It rejoins any array elements and…