Complete the code to join array elements with a comma.
<?php $array = ['apple', 'banana', 'cherry']; $result = [1](',', $array); echo $result; ?>
explode which splits strings, not joins arrays.The implode function joins array elements into a string using the specified separator.
Complete the code to join array elements with a space.
<?php $words = ['Hello', 'world', '!']; $text = [1](' ', $words); echo $text; ?>
explode which splits strings into arrays.implode joins array elements into a string separated by the given string.
Fix the error in the code to correctly join array elements with a dash.
<?php $parts = ['2024', '06', '15']; $date = [1]('-', $parts); echo $date; ?>
implode.The implode function joins array elements into a string. Note the order: separator first, array second.
Complete the code to join array elements with a colon and assign to variable.
<?php $time = ['12', '30', '45']; $joined = [1](':', $time); echo $joined; ?>
Use implode with ':' as the separator to join the array elements.
Fill all three blanks to join array keys and values with '=' and pairs with '&'.
<?php $params = ['name' => 'John', 'age' => 30]; $pairs = []; foreach ($params as $key => $value) { $pairs[] = $key . '[1]' . $value; } $query = [2]('[3]', $pairs); echo $query; ?>
Use = to join key and value, implode to join pairs, and & as separator.
