php manipulation of one data simple basic php code execution -


i have solve assignment question touches on simple basic php codings learnt in class far..the question goes:

arithmetic-assignment operators perform arithmetic operation on variable @ same time assigning new value. write script reproduce output below. manipulate 1 variable using no simple arithmetic operators produce values given in statements.

hint: in script each statement ends "value $variable."

output:  value 8. add 2. value 10. subtract 4. value 6. multiply 5. value 30. divide 3. value 10. increment value one. value 11. decrement value one. value 10. 

do guys think question telling me use arrays??

coz i'm gonna take swing @ , assume arrays question wants me write.. here sample answer. hope guys check out , see if answer meets question's needs:

    <?php     $numbers=array("8","10","6","30","11");     echo "value {$numbers[0]}.<br>";     echo "add 2. value {$numbers[1]}.<br>";     echo "subtract 4. value {$numbers[2]}.<br>";     echo "multiply 5. value now{$numbers[3]}.<br>";     echo "divide 3. value {$numbers[1]}.<br>";     echo "increment value one. value {$numbers[4]}.<br>";     echo "decrement value one. value {$numbers[1]}.<br>";     ?> 

i believe asked use arithmetic operators.

if should like:

<?php     $value = 8;     echo "value $value.<br>";     echo "add 2. value " . $value+=2 . ".<br>";     echo "subtract 4. value " . $value-=4 . ".<br>";     echo "multiply 5. value now" . $value*=5 . ".<br>";     // rest assignment ?> 

you can play here.

note:

<br> html. if asked use php use \r\n.


Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -