Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP return array of matching KEY NAMES and there values
    text
    copied!<p>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.</p> <pre><code>$properties = array( array( PropertyID =&gt; 2845, Address_1 =&gt; "1234 Any street", MEDIA_IMAGE_00 =&gt; "23428.jpg", MEDIA_IMAGE_TEXT_00 =&gt; "Front of House", MEDIA_IMAGE_01 =&gt; "29872.jpg", MEDIA_IMAGE_TEXT_01 =&gt; "Master Bedroom", MEDIA_IMAGE_02 =&gt; "29834.jpg" ), array( PropertyID =&gt; 2845, Address_1 =&gt; "555 This street", MEDIA_IMAGE_00 =&gt; "234234.jpg", MEDIA_IMAGE_TEXT_00 =&gt; "Front of House", MEDIA_IMAGE_01 =&gt; "298724.jpg", MEDIA_IMAGE_TEXT_01 =&gt; "Second Bedroom", MEDIA_IMAGE_02 =&gt; "298346.jpg" ), array( PropertyID =&gt; 2845, Address_1 =&gt; "333 Main street", MEDIA_IMAGE_00 =&gt; "2342845.jpg", MEDIA_IMAGE_TEXT_00 =&gt; "Lounge", MEDIA_IMAGE_01 =&gt; "2987246.jpg", MEDIA_IMAGE_TEXT_01 =&gt; "Front of House", MEDIA_IMAGE_02 =&gt; "2983434.jpg" ), ); </code></pre> <p>There is a <strong>massive</strong> amount of data in each sub array I've trimmed it down for length...</p> <p>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.</p> <p>So now that the background is out of the way.</p> <p>How do I pull <strong>just the keys of the array that match</strong> 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:</p> <pre><code>$property_images = array( array( PropertyID =&gt; 2845, IMAGE =&gt; "23428.jpg", IMAGE_TEXT =&gt; "Front of House"), array( PropertyID =&gt; 2845, IMAGE =&gt; "29872.jpg", IMAGE_TEXT =&gt; "Master Bedroom", array( PropertyID =&gt; 2845, MEDIA_IMAGE_02 =&gt; "29834.jpg" IMAGE_TEXT =&gt; "Living Room" </code></pre> <p>I've tried sscanf to no avail and fiddle around with array_keys but haven't managed to figure out how to target the <strong>key names</strong> rather than the key values...</p> <p>Thanks for your help in advance!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload