Hi all
I’m stuck on this an i’m hopping to get some help.
I need to search an array of albums and videos (videos are child arrays of the album) for a value (in my case a tag) and then return the ‘video’ of the matched value as a new array (Not separated by albums).
This is a small example of how my main array is formatted (actual array contains over 20 albums and each album contains between 3 and 10 videos. Each video contains 4+ tags):
[code=php]
Array
(
[0] => Array
(
[id] => 123456
[title] => Album 1 title
[description] => This is my ALBUM description
[url] => http:/example.com
[total] => 2
[thumb] => http:/example.com/image-thumb.jpg
[videos] => Array
(
[0] => Array
(
[id] => 345678
[title] => Video 1 title
[privacy] => anywhere
[url] => http:/example.com
[album] => Album 1 title
[description] => This is my VIDEO description
[tags] => Array
(
[0] => tag_0
[1] => tag_1
[2] => tag_2
)
[thumbs] => Array
(
[0] => http:/example.com/image-thumb0.jpg
[1] => http:/example.com/image-thumb1.jpg
[2] => http:/example.com/image-thumb2.jpg
[3] => http:/example.com/image-thumb3.jpg
)
)
[1] => Array
(
[id] => 456789
[title] => Video 2 title
[privacy] => anywhere
[url] => http:/example.com
[album] => Album 1 title
[description] => This is my VIDEO description
[tags] => Array
(
[0] => tag_2
[1] => tag_3
[2] => tag_4
)
[thumbs] => Array
(
[0] => http:/example.com/image-thumb0.jpg
[1] => http:/example.com/image-thumb1.jpg
[2] => http:/example.com/image-thumb2.jpg
[3] => http:/example.com/image-thumb3.jpg
)
)
)
)
[1] => Array
(
[id] => 234567
[title] => Album 2 title
[description] => This is my ALBUM description
[url] => http:/example.com
[total] => 2
[thumb] => http:/example.com/image-thumb.jpg
[videos] => Array
(
[0] => Array
(
[id] => 567890
[title] => Video 3 title
[privacy] => anywhere
[url] => http:/example.com
[album] => Album 2 title
[description] => This is my VIDEO description
[tags] => Array
(
[0] => tag_5
[1] => tag_4
[2] => tag_3
)
[thumbs] => Array
(
[0] => http:/example.com/image-thumb0.jpg
[1] => http:/example.com/image-thumb1.jpg
[2] => http:/example.com/image-thumb2.jpg
[3] => http:/example.com/image-thumb3.jpg
)
)
[1] => Array
(
[id] => 567895
[title] => Video 4 title
[privacy] => anywhere
[url] => http:/example.com
[album] => Album 2 title
[description] => This is my VIDEO description
[tags] => Array
(
[0] => tag_2
[1] => tag_3
[2] => tag_4
)
[thumbs] => Array
(
[0] => http:/example.com/image-thumb0.jpg
[1] => http:/example.com/image-thumb1.jpg
[2] => http:/example.com/image-thumb2.jpg
[3] => http:/example.com/image-thumb3.jpg
)
)
)
)
)
for example I would like to search for all videos that contain the value [B][COLOR=”Red”[COLOR=”RoyalBlue”][B][tags]
Hope this makes sense. Would be good if tis was a function that would be quite robust if the array structure did for some reason change slightly.
[COLOR=”Red”][B]tag_2
eg:
[code=php]$search_term = ‘tag_2’;
search_my_array($search_term, $my_array)
This would be the returned array if I searched [COLOR=”Red”][B]tag_2
[code=php]Array
(
[0] => Array
(
[id] => 345678
[title] => Video 1 title
[privacy] => anywhere
[url] => http:/example.com
[album] => Album 1 title
[description] => This is my VIDEO description
[tags] => Array
(
[0] => tag_0
[1] => tag_1
[2] => tag_2
)
[thumbs] => Array
(
[0] => http:/example.com/image-thumb0.jpg
[1] => http:/example.com/image-thumb1.jpg
[2] => http:/example.com/image-thumb2.jpg
[3] => http:/example.com/image-thumb3.jpg
)
)
[1] => Array
(
[id] => 456789
[title] => Video 2 title
[privacy] => anywhere
[url] => http:/example.com
[album] => Album 1 title
[description] => This is my VIDEO description
[tags] => Array
(
[0] => tag_2
[1] => tag_3
[2] => tag_4
)
[thumbs] => Array
(
[0] => http:/example.com/image-thumb0.jpg
[1] => http:/example.com/image-thumb1.jpg
[2] => http:/example.com/image-thumb2.jpg
[3] => http:/example.com/image-thumb3.jpg
)
)
[3] => Array
(
[id] => 567895
[title] => Video 4 title
[privacy] => anywhere
[url] => http:/example.com
[album] => Album 2 title
[description] => This is my VIDEO description
[tags] => Array
(
[0] => tag_2
[1] => tag_3
[2] => tag_4
)
[thumbs] => Array
(
[0] => http:/example.com/image-thumb0.jpg
[1] => http:/example.com/image-thumb1.jpg
[2] => http:/example.com/image-thumb2.jpg
[3] => http:/example.com/image-thumb3.jpg
)
)
)
Any help is much appreciated.
Cheers
C