I'm having a terrible time trying to pull out some values out of an array. Here is a slimmed down version of the array.
$properties = array( array( PropertyID => 2845,
Address_1 => "1234 Any street",
MEDIA_IMAGE_00 => "23428.jpg",
MEDIA_IMAGE_TEXT_00 => "Front of House",
MEDIA_IMAGE_01 => "29872.jpg",
MEDIA_IMAGE_TEXT_01 => "Master Bedroom",
MEDIA_IMAGE_02 => "29834.jpg"
),
array( PropertyID => 2845,
Address_1 => "555 This street",
MEDIA_IMAGE_00 => "234234.jpg",
MEDIA_IMAGE_TEXT_00 => "Front of House",
MEDIA_IMAGE_01 => "298724.jpg",
MEDIA_IMAGE_TEXT_01 => "Second Bedroom",
MEDIA_IMAGE_02 => "298346.jpg"
),
array( PropertyID => 2845,
Address_1 => "333 Main street",
MEDIA_IMAGE_00 => "2342845.jpg",
MEDIA_IMAGE_TEXT_00 => "Lounge",
MEDIA_IMAGE_01 => "2987246.jpg",
MEDIA_IMAGE_TEXT_01 => "Front of House",
MEDIA_IMAGE_02 => "2983434.jpg"
),
);
There is a massive amount of data in each sub array I've trimmed it down for length...
I'm inserting this data into a MySQL database, however, I'm inserting the images into a separate table [PropertyID, Image, ImageText] because some properties may have more images than others.
So now that the background is out of the way.
How do I pull just the keys of the array that match and there info into another array? So that I would end up with an array from the above that would end up with something similar to:
$property_images = array( array( PropertyID => 2845,
IMAGE => "23428.jpg",
IMAGE_TEXT => "Front of House"),
array( PropertyID => 2845,
IMAGE => "29872.jpg",
IMAGE_TEXT => "Master Bedroom",
array( PropertyID => 2845,
MEDIA_IMAGE_02 => "29834.jpg"
IMAGE_TEXT => "Living Room"
I've tried sscanf to no avail and fiddle around with array_keys but haven't managed to figure out how to target the key names rather than the key values...
Thanks for your help in advance!