for the first time I encounter such a problem. It works;
function translate($google) {
$en = array(
"Mother", "Father"
);
$de= array(
"Mutter", "Vater"
);
$s = str_replace($en,$de,$google);
return $s;}
But this does not work
$en = array(
"Mother", "Father"
);
$de= array(
"Mutter", "Vater"
);
function translate($google, $en, $de) {
$s = str_replace($en,$de,$google);
return $s;
}
where do i make mistakes?
Last time I'll use it like this;
echo translate(fonkfonk(str_replace(array("
","","\t"),array("","",""),file_get_contents($cache))));
Your problem is that you're not providing the values of $en
and $de
to your function when calling it.
$en = array("Mother", "Father");
$de = array("Mutter", "Vater");
function translate($google, $en, $de) {
$s = str_replace($en,$de,$google);
return $s;
}
echo translate(fonkfonk(.....)); // error because translate() does not know what
// $en and $de are supposed to be
You are only providing the result of the fonkfonk()
function as the first argument ($google
) and not providing a second and third argument.
What you should do is either provide the values of $en
and $de
in your function call, or import them when you define the function:
function translate($google, $en, $de) {
$s = str_replace($en,$de,$google);
return $s;
}
$en = array("Mother", "Father");
$de = array("Mutter", "Vater");
echo translate(fonkfonk(.....), $en, $de);
Or:
$en = array("Mother", "Father");
$de = array("Mutter", "Vater");
function translate($google) use ($en, $de) {
$s = str_replace($en,$de,$google);
return $s;
}
echo translate(fonkfonk(.....));