1

I realise that this question has been asked a number of times but I am yet to find a solution to this problem.

I am using pChart (pData v2.1.4). It works fine on the hosting site which is running php v5.6.30 but I getting a fatal error with the same code on XAMMP which is running php v7.2.5.

The error refers to this line in pData: (NOTE: pData is a class written by a third party and so not my code)

function convertToArray($Value)
    { $Values = ""; $Values[] = $Value; return($Values); }

Any suggestions as to how to resolve the problem? I have tried declaring $Values as an array earlier in the code but this seemed to cause more errors.

Also, is this php version related and an error that I am going to start getting if my hosting site moves on to a newer version php?

4 Answers 4

1

You have declared $Values as string:

$Values = "";

Fix replacing with array:

function convertToArray($Value)
{
    $Values = [];
    $Values[] = $Value;
    return $Values;
}

But, in my opinion, there is no reason to use this function. In your code, just define an array of the same variable with:

$Value = [$Value];

It will do the same as your function.

Sign up to request clarification or add additional context in comments.

Comments

1

You can't convert string to array ($Values = ""; $Values[] = $Value;), so right variant:

function convertToArray($value) {
    return [$value];
}

Comments

1

Values should declared as Array Try this.

function convertToArray($Value){
 $Values = [];
 $Values[] = $Value;
 return $Values;
}

Comments

0

Try this,

function convertToArray($Value){
   $Values = array(); // initialize 

   if ( isset($Value) ) $Values[] = $Value; 

   return($Values); 
}

Let me know if it works or not.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.