.Hello y'all! I'm trying to go through an array of variable and pull out each variable's name and price to put in a new array.
While doing this I'm checking for duplicates where if one is found the loop checks for how many already exist in the new array and adds a "0" behind the last decimal of the duplicate (so 0.50 becomes 0.500) for as many already exist and then add its to the new array. The idea being that all numbers should be unique even if they have the same value.
For some reason I keep getting a "Undefined index: 55.00" message. 55.00 is the first value I am trying to pass. What confuses me is why am I getting an "undefined index" message when I can see that it is able to find the correct variable that I am trying to find.
Any clarification or pointers where I am going wrong would be greatly appreciated!
Thank y'all so much!
Here is the code:
$house_prices is the original array that I have accessed through the controller
<?php
$house_prices_array[''] = 'Gates';
$temporary_array = array();
/*Checking for duplicate prices for dropdown select menu*/
foreach($house_prices as $price){
if(in_array($price->price, $temporary_array)){
/*1.)If duplicate exists, find how many, 2.)add price to temporary array, 3.) then add corresponding zeroes as decimal numbers to create unique number for dropdown menu and then 4.)add it to the dropdown menu options array.*/
/*1.*/
$price_counts = array_count_values($temporary_array);
$number_of_current_price = $price_counts[$price->price];
/*2.*/
$temporary_array[$price->price];
/*3.*/
$price_amount = $price->price;
for ( $i = 1; i <= $number_of_current_price; $i++) {
$price_amount .= "0";
}
/*4.*/
$gate_prices_array[$price_new_amount];
} else {
$temporary_array[$price->price];
$gate_prices_array[$price->price] = $price->name;
}
}
?>