$line [1] = Intval ($line [1]); What does this mean by writing this?
Create short variable name
$DOCUMENT _root = $_server[' document_root ');
?>
<title>Bob ' s Auto parts-customer Orders</title>
Bob ' s Auto Parts
Customer Orders
Read in the entire file.
Each order becomes a element in the array
ers = File ("$DOCUMENT _root/. /orders/orders.txt ");
Count the number of orders in the array
_of_orders = count (ers);
if (_of_orders = = 0) {
echo "No orders pending.
Please try again later.
";
}
echo "
\ n ";echo "
Order Date |
Tires |
| Oil
Spark Plugs |
| Total
Address |
"; for ($i =0; $i < _of_orders; $i + +) {//split up all line $line = explode ("\ t", ers [$i]); Keep only the number of items ordered $line [1] = Intval ($line [1]); $line [2] = Intval ($line [2]); $line [3] = Intval ($line [3]); Output each order echo "
". $line [0]." |
". $line [1]." |
". $line [2]." |
". $line [3]." |
". $line [4]." |
". $line [5]." |
";}echo "
";
?>
$line [1] = Intval ($line [1]); What does this mean by writing this? The Intval manual is the integer value that describes intval returns the variable var by using a specific binary conversion (by default, decimal). But what is the effect of assigning this integer value to $line[1]?
Share to: more
------Solution--------------------
Intval () variable turns into an integer type
$line [2] = Intval ($line [2]);
$line [3] = Intval ($line [3]);
Variables that are converted to integer types regroup arrays $line
You can also re-assign to variables
$line _b = Intval ($line [2]);
$line _c = Intval ($line [3]);
Then your template shows that the corresponding needs change.
------Solution--------------------
$line [1] = Intval ($line [1]);
Ensures that the value of the final $line [1] is an integer
Besides, the original author has already made a statement
38 lines have keep only the number of items ordered