Instantly share code, notes, and snippets.

Embed
What would you like to do?
Contoh passing by reference 2
<?php
// Tampilkan nilai array
$arr = [1, 2, 3];
echo implode(', ', $arr), "\n";
// Melakukan looping untuk setiap elemen array
// menggunakan teknik passing by reference
foreach ($arr as &$value) {}
echo implode(', ', $arr), "\n";
// Melakukan looping untuk setiap elemen array
// menggunakan teknik passing by value
foreach ($arr as $value) {}
echo implode(', ', $arr), "\n";
// Hasil:
// 1, 2, 3
// 1, 2, 3
// 1, 2, 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment