Skip to content

Instantly share code, notes, and snippets.

@phpfiddle
Created April 3, 2020 04:01
Show Gist options
  • Save phpfiddle/31c2fa96bad2320230b908ac91b3e6ac to your computer and use it in GitHub Desktop.
Save phpfiddle/31c2fa96bad2320230b908ac91b3e6ac to your computer and use it in GitHub Desktop.
[ Posted by Sgoehre ] testtesttedst
<?php
$mitarbeiter = ["Bob","Peter","Lisa"];
function ersetzen($array, $wert, $wert_neu) {
if(in_array($wert,$array)) {
$index = array_search($wert, $array);
$array[$index] = $wert_neu;
echo "Der Wert $wert an der Stelle / mit dem Index $index ist in dem Array enthalten und wurde mit $wert_neu ersetzt";}
}
ersetzen($mitarbeiter, "Bob", "Alexa");
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment