Jump to content

Understanding the Array Diff and Intersect Functional Family


iwato

Recommended Posts

Question One: Have you ever tried to figure out why there are so many variations of the array_intersect() and array_diff() functions?Question Two: More importantly would you like a way to find the one you want at a glance?Code Description: The following two arrays contain all the information you need to know to distinguish among these two groups of functions.The top two subarrays in each main array provide a table caption and column headers, should you like to make a table.

			$array_intersect = array(				'table_caption' => 'The Array Intersect Family - A Comparison of Use',				'column_header' => array('intersect function','value matches', 'key matches', 'value function', 'key function'),				'array_intersect' => array('value' => '1', 'key' => '0', 'val_func' => '0', 'key_func' => '0'),				'array_intersect_key' => array('value' => '0', 'key' => '1', 'val_func' => '0', 'key_func' => '0'),				'array_intersect_assoc' => array('value' => '1', 'key' => '1', 'val_func' => '0', 'key_func' => '0'),				'array_uintersect' => array('value' => '1', 'key' => '0', 'val_func' => '1', 'key_func' => '0'),				'array_intersect_ukey' => array('value' => '0', 'key' => '1', 'val_func' => '0', 'key_func' => '1'),				'array_uintersect_assoc' => array('value' => '1', 'key' => '1', 'val_func' => '1', 'key_func' => '0'),				'array_intersect_uassoc' => array('value' => '1', 'key' => '1', 'val_func' => '0', 'key_func' => '1'),				'array_uintersect_uassoc' => array('value' => '1', 'key' => '1', 'val_func' => '1', 'key_func' => '1')				);			$array_diff = array(				'table_caption' => 'The Array Diff Family - A Comparison of Use',				'column_header' => array('intersect function','value matches', 'key matches', 'value function', 'key function'),				'array_diff' => array('value' => '1', 'key' => '0', 'val_func' => '0', 'key_func' => '0'),				'array_diff_key' => array('value' => '0', 'key' => '1', 'val_func' => '0', 'key_func' => '0'),				'array_diff_assoc' => array('value' => '1', 'key' => '1', 'val_func' => '0', 'key_func' => '0'),				'array_udiff' => array('value' => '1', 'key' => '0', 'val_func' => '1', 'key_func' => '0'),				'array_diff_ukey' => array('value' => '0', 'key' => '1', 'val_func' => '0', 'key_func' => '1'),				'array_udiff_assoc' => array('value' => '1', 'key' => '1', 'val_func' => '1', 'key_func' => '0'),				'array_diff_uassoc' => array('value' => '1', 'key' => '1', 'val_func' => '0', 'key_func' => '1'),				'array_udiff_uassoc' => array('value' => '1', 'key' => '1', 'val_func' => '1', 'key_func' => '1')				);My way to say thanks to everyone for your help.Roddy

Link to comment
Share on other sites

There's little need to say this, but I'll say it anyway - if you build yourself a blog, you can count me in as your regular reader :) .

Link to comment
Share on other sites

There's little need to say this, but I'll say it anyway - if you build yourself a blog, you can count me in as your regular reader.
As always, thank you for your encouragement and ever ready helpfulness.Roddy
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...