midwestdev
6 months ago

Merge Two Arrays Based On Partial String in Key Value

Posted 6 months ago by midwestdev

I have got two arrays that I need to merge, the only way to merge the data is by one tiny partial piece of information in CAT_DESCRIPTION and CIRCUIT a 6 digit number. I can use a regular expression to /[0-9]{6}/ but I am not quite sure how to map the data.

$data1 returns an array like this

object(stdClass)#683 (3) {
    ["CIRCUIT"]=>  string(19) ".LXFP.144374..LB"
    ["DESCRIPTION"]=>   string(15) "This is the description"
    ["INSTALL_DATE"]=> string(10) "2015-09-25"
  }

$data2 returns an array like this

  object(stdClass)#687 (1) {
       ["CAT_DESCRIPTION"]=> string(37) "LXFP/144374//LB Slightly different description"
  }

Please sign in or create an account to participate in this conversation.