Answer the question
In order to leave comments, you need to log in
How to fix Fatal error: Cannot redeclare isAnyElementInArray?
Previously, there was one component on the page, then, if necessary, it was necessary to use it several times:
here is a part of the code from the component that caused the error
function isAnyElementInArray($arNeedle, $arHaystack)
{
foreach ($arNeedle as $curNeedle)
{
if (in_array($curNeedle,$arHaystack))
{
return $curNeedle;
}
}
return false;
}
Fatal error: Cannot redeclare isAnyElementInArray() (previously declared in /home/bitrix/www/bitrix/templates.........) in /home/bitrix/www/bitrix/templates......... on line 15
Answer the question
In order to leave comments, you need to log in
if(!function_exists('isAnyElementInArray')) {
function isAnyElementInArray($arNeedle, $arHaystack) {}
}
You already have an isAnyElementInArray function and you are trying to declare another one with the same name.
Solutions:
Find where it already exists and use it
Change the name of this new feature
Learn from namespaces
and what does she mean?Not ashamed? If only the translator drove this message.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question