Search the Community
Showing results for tags 'php arrays'.
-
Hi I working on a register page with prepared statements but i'm having an issue detective why I am receiving this error, could anyone suggest solutions I'm fairly new to this code Parse error: syntax error, unexpected T_DOUBLE_ARROW $stmt = $db->prepare("SELECT email FROM login WHERE email=:email1 LIMIT 1"); $arr = $array( 'email'=>$email); ArrayBinder($stmt, $arr); try{ $stmt->execute(); } catch(PDOException $e){ echo errorHandle($e); } while($row = $stmt->fetch(PDO::Fetch_ASSOC)){ print_r($row); }
-
Hello guys i want to know how can i iterate this array. stdClass Object ( [new_occ] => Array ( [0] => Array # This is the room number ( [adults] => 2 [children] => Array ( [0] => 0 [1] => 0 [2] => 0 ) ) [1] => Array ( [adults] => 1 ) [2] => Array ( [adults] => 2 [children] => Array ( [0] => 1 [1] => 1 [2] => 1 ) ) ) ) i want to print each of the elements but for adults and children, i only want the sum of the elements for each room. Thanks in advance.
-
Hello Everyone, I am working on a CMS site and I'm stuck very badly with arrays. I don't have much experience with arrays. In fact, this is probably the first time I have used them this heavily. Here is my situation: I have a for each loop with $i++; which takes values from sessions and puts them into arrays: $bundle_pickup[$i]['bundle_ID']=$bundle_ID; $bundle_pickup[$i]['pickup_date']=$_SESSION['bundle'][$bundle_ID]['pickup_date']; $bundle_pickup[$i]['pickup_time']=$_SESSION['bundle'][$bundle_ID]['pickup_time']; $bundle_pickup prints the following total results: Array ( [1] => Array ( [bundle_ID] => 3 [pickup_date] => 2012-11-08 [pickup_time] => 9 AM to 12 PM ) [2] => Array ( [bundle_ID] => 4 [pickup_date] => 2012-11-08 [pickup_time] => 9 AM to 12 PM ) [3] => Array ( [bundle_ID] => 5 [pickup_date] => 2012-11-08 [pickup_time] => 9 AM to 12 PM ) [4] => Array ( [bundle_ID] => 6 [pickup_date] => 2012-11-08 [pickup_time] => 9 AM to 12 PM ) ) Everything so far is good. Here is what I need to do: I need to loop through $bundle_pickup array and find out which arrays are different. I need to get $bundle_pickup['bundle_ID'] of all the unique arrays The idea is, if the customer picks same pickup date and time for all bundles, he only pays one pickup charge. If he chooses multiple pickup dates or times, he will need to pay multiple charges. If two bundles have same pickup dates/times and other two have same ( but different than first two ), the customer will pay two pick up charges. Since this is a CMS site, I will not know the bundle_ID, pickup dates, pickup times and order of the bundles. If anyone can suggest how I can get $bundle_pickup['bundle_ID'] of all the unique arrays, that would be greatly appreciated. Once I have the IDs, I can use them to fetch other data from the database. Thanks in advance. Jatt Surma
- 2 replies
-
- php arrays
- multidimensional arrays
- (and 3 more)