How how do you change a value inside a variable, i'm having trouble executing this but can't find any examples for dummies.

Here is an example, just add word global

$var = "Mercedes";
function checkcar() {
     global $var;

     if("Condition") {
        $var = "BMW";
     }
}
Member Avatar for diafol

Don't use global if you can possibly help it.

Changing a variable's value in normal usage:

echo "<pre>";
$myVar = 10;
echo $myVar . "\n";
$myVar = 20;
echo $myVar . "\n";
$myVar = $myVar + 30; //gives 50 - can use shortcut of $myVar += 30 to give 50
echo $myVar . "\n";
$myVar = "I'm now a string";
echo $myVar . "\n";
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.