Last active
November 9, 2023 12:06
-
-
Save alvaro-prieto/041ab2fa810218396be2ad13e2db22ea to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Foreach en php | |
## Si queremos modificar o agregar un campo de un array preexistente | |
```php | |
//Agregamos una nueva columna sin hacer copias del objeto, modificándolo directamente | |
foreach ($datos as &$elemento) { | |
$elemento['url'] = "<a href='" . $elemento['enlace'] . "'>" . $elemento['entidad'] . "</a>"; | |
} | |
unset($elemento); | |
//por seguridad, par evitar que se cambie algo sin querer | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment