PHP syntax error in function, don't know why

Bryan

I'm getting a syntax error and I can't figure out why. "Parse error: syntax error, unexpected '{' on line 6"

function ExtractCustomField($fieldName, $customFields) {
// $customFields might be an object, NULL, or an array.
$parsed = array();
if (is_array($customFields) == false && $customFields != null) {
$parsed = array($customFields);
} else (is_array($customFields)) {
$parsed = $customFields;
}

// loop through the fields and find the one we are looking for
$returnField = null;
foreach($field as $customFields) {
if ($field->Name == $fieldName) {
$returnField = $field;
break;
}
}

return $returnField
}
Utkarsh Dixit

You forget to put semicolon after $returnField, also use elseif instead of else (else don't need any arguments). Use the code below

function ExtractCustomField($fieldName, $customFields) {
// $customFields might be an object, NULL, or an array.
$parsed = array();
if (is_array($customFields) == false && $customFields != null) {
$parsed = array($customFields);
} elseif (is_array($customFields)) {
$parsed = $customFields;
}

// loop through the fields and find the one we are looking for
$returnField = null;
foreach($field as $customFields) {
if ($field->Name == $fieldName) {
$returnField = $field;
break;
}
}

return $returnField;
}

Hope this helps you

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Syntax error on open() in Python 3, don't know why

From Dev

ERROR in SQL syntax near Integer data type while creating a table, don't know why it's failing

From Dev

Get 404 error and don't know why

From Dev

SMTP Error, I don't know why

From Dev

php error - don't know how to fix it

From Dev

php error - don't know how to fix it

From Dev

ReflectionException in Route.php line 335: Function () does not exist don't know why

From Dev

File open prompt Function code not working - don't know why

From Dev

My prime number function is broken but I don't know why

From Dev

Haskell, Don't know why this has a *parse error on input ‘if’*

From Dev

Task_Dispose_NotCompleted error but i don't know why

From Dev

Don't know why I receive `error: forward declaration of <class>`

From Dev

Haskell, Don't know why this has a *parse error on input ‘if’*

From Dev

I keep getting this error message and I don't know why

From Dev

elif python3.5.3 error don't know why

From Dev

Don't know why I am getting StopIteration error

From Dev

Why is there a syntax error if I don't write 'if' in an END block of AWK?

From Dev

Why is there a syntax error if I don't write 'if' in an END block of AWK?

From Dev

Why I don't get syntax error in this sample code?

From Dev

Error C2061 Syntax Error Identifier -- I don't know what I'm doing wrong

From Dev

Function syntax error in PHP

From Dev

é instead of "é", definitely don't know why

From Dev

I don't know why this canvas is null

From Dev

resizeBy not working and don't know why

From Dev

Getting null pointer, don't know why

From Dev

Don't know why Polymer is not working

From Dev

Sound is gone, I don't know why

From Dev

Getting exception ClassNotFoundException and don't know why

From Dev

é instead of "é", definitely don't know why

Related Related

  1. 1

    Syntax error on open() in Python 3, don't know why

  2. 2

    ERROR in SQL syntax near Integer data type while creating a table, don't know why it's failing

  3. 3

    Get 404 error and don't know why

  4. 4

    SMTP Error, I don't know why

  5. 5

    php error - don't know how to fix it

  6. 6

    php error - don't know how to fix it

  7. 7

    ReflectionException in Route.php line 335: Function () does not exist don't know why

  8. 8

    File open prompt Function code not working - don't know why

  9. 9

    My prime number function is broken but I don't know why

  10. 10

    Haskell, Don't know why this has a *parse error on input ‘if’*

  11. 11

    Task_Dispose_NotCompleted error but i don't know why

  12. 12

    Don't know why I receive `error: forward declaration of <class>`

  13. 13

    Haskell, Don't know why this has a *parse error on input ‘if’*

  14. 14

    I keep getting this error message and I don't know why

  15. 15

    elif python3.5.3 error don't know why

  16. 16

    Don't know why I am getting StopIteration error

  17. 17

    Why is there a syntax error if I don't write 'if' in an END block of AWK?

  18. 18

    Why is there a syntax error if I don't write 'if' in an END block of AWK?

  19. 19

    Why I don't get syntax error in this sample code?

  20. 20

    Error C2061 Syntax Error Identifier -- I don't know what I'm doing wrong

  21. 21

    Function syntax error in PHP

  22. 22

    é instead of "é", definitely don't know why

  23. 23

    I don't know why this canvas is null

  24. 24

    resizeBy not working and don't know why

  25. 25

    Getting null pointer, don't know why

  26. 26

    Don't know why Polymer is not working

  27. 27

    Sound is gone, I don't know why

  28. 28

    Getting exception ClassNotFoundException and don't know why

  29. 29

    é instead of "é", definitely don't know why

HotTag

Archive