Skip to content

Instantly share code, notes, and snippets.

@cjzeven
Last active May 12, 2017 16:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cjzeven/057aff01d98e67cf5f0ee6703b91b260 to your computer and use it in GitHub Desktop.
Save cjzeven/057aff01d98e67cf5f0ee6703b91b260 to your computer and use it in GitHub Desktop.
<?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";
// Unset reference
unset($value);
// 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, 3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment