View Single Post
  #27 (permalink)  
Old 04-22-09, 05:27 PM
jaimenacach jaimenacach is offline
New Member
 
Join Date: Apr 2009
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Cant figure out some notation in PHP

Hello,

I would like to know if someone can explain to me some of the code that user "job0107" used for declaring some variables from post #23. Part of it is shown below. It's part of the code for the function called showCart() within the ShoppingCart Class on ShoppingCart.php.

I don't understand how the following declarations works, or what they mean. How is the notation $ProdID = $Order[0] ? $Order[0] : ""; read, or what does it mean?
What does the "?" and the ":" represent?
I've tried searching for the meaning online. But can't find anything, or just don't know how to Google for it.

I know that the way it's written WORKS properly and that the variables do print out the correct TABLE name and product ID. I just want to know why.

Once the multidimensional array $Orders is broken down,
Why can't we just declare the following:
$Table_Name = $Order[1];
$ProdID = $Order[0];

Thanks for the help!


PHP Code:

$sw 0;
       for(
$i=0;$i<count($this->Orders);$i++) {
          
$Order $this->Orders[$i];
          
$Table_Name $Order[1] ? $Order[1] : "";
          echo 
"$Table_Name<br />";
          
$ProdID $Order[0] ? $Order[0] : "";
          
$OrderQTY 1;
          if(
$Table_Name && $ProdID) {
             if(
$sw == 0) {
                echo 
"<table width='100%' border='1'><tr><th>Remove Item</th><th>Product</th><th>Quantity</th><th>Price Each</th></tr>";
                
$sw 1;
             } 
Jaime Nacach

Last edited by jaimenacach; 04-22-09 at 05:31 PM.
Reply With Quote