Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 01/31/2024 in all areas

  1. I guess I'll never know how and why they were created in such an unusable format. You first task is to correct that shortcoming and restructure the two arrays. I suggest $alpha1 = [ "OID=.1.3.6.1.4.1.14823.2.2.1.1.2.1.1.2.10.12.15.161, Type=OctetString, Value= D8 B0 53 C4 01 E5", "OID=.1.3.6.1.4.1.14823.2.2.1.1.2.1.1.2.10.15.65.47, Type=OctetString, Value= 5C D0 6E F0 F9 2E", "OID=.1.3.6.1.4.1.14823.2.2.1.1.2.1.1.2.10.36.240.52, Type=OctetString, Value= 84 B1 E4 6E 93 4F", "OID=.1.3.6.1.4.1.14823.2.2.1.1.2.1.1.2.10.36.240.53, Type=OctetString, Value= 1C 6A 76 41 09 B9", "OID=.1.3.6.1.4.1.14823.2.2.1.1.2.1.1.2.10.36.240.59, Type=OctetString, Value= 84 B1 E4 70 C7 D9", "OID=.1.3.6.1.4.1.14823.2.2.1.1.2.1.1.2.10.36.240.60, Type=OctetString, Value= 6C 7E 67 41 27 C3", "OID=.1.3.6.1.4.1.14823.2.2.1.1.2.1.1.2.10.36.240.67, Type=OctetString, Value= CE B9 5E 32 17 61" ]; $alpha2 = [ "OID=.1.3.6.1.4.1.14823.2.2.1.1.2.1.1.3.10.12.15.161, Type=OctetString, Value=GA871", "OID=.1.3.6.1.4.1.14823.2.2.1.1.2.1.1.3.10.15.65.47, Type=OctetString, Value=MC990", "OID=.1.3.6.1.4.1.14823.2.2.1.1.2.1.1.3.10.36.240.52, Type=OctetString, Value=svc_rover@gstt.local", "OID=.1.3.6.1.4.1.14823.2.2.1.1.2.1.1.3.10.36.240.53, Type=OctetString, Value=svc_rover@gstt.local", "OID=.1.3.6.1.4.1.14823.2.2.1.1.2.1.1.3.10.36.240.59, Type=OctetString, Value=svc_rover@gstt.local", "OID=.1.3.6.1.4.1.14823.2.2.1.1.2.1.1.3.10.36.240.60, Type=OctetString, Value=svc_rover@gstt.local", "OID=.1.3.6.1.4.1.14823.2.2.1.1.2.1.1.3.10.36.240.67, Type=OctetString, Value=svc_rover@gstt.local" ]; $alpha1 = array_map('convert', $alpha1); // apply the calback function convert() to each element $alpha2 = array_map('convert', $alpha2); function convert($str) // callback function { $a = explode(', ', $str); $res = []; foreach ($a as $str2) { $b = explode('=', $str2); if ($b[0] == 'OID') { // we only want the last 4 elements $res[$b[0]] = join('.', array_slice(explode('.', $b[1]), -4)); } else $res[$b[0]] = $b[1]; } return $res ; } You now have two arrays in this format, which are much more easily processed... $arr = array ( 0 => array ( 'OID' => '10.12.15.161', 'Type' => 'OctetString', 'Value' => ' D8 B0 53 C4 01 E5', ), 1 => array ( 'OID' => '10.15.65.47', 'Type' => 'OctetString', 'Value' => ' 5C D0 6E F0 F9 2E', ), 2 => array ( 'OID' => '10.36.240.52', 'Type' => 'OctetString', 'Value' => ' 84 B1 E4 6E 93 4F', ), 3 => array ( 'OID' => '10.36.240.53', 'Type' => 'OctetString', 'Value' => ' 1C 6A 76 41 09 B9', ), 4 => array ( 'OID' => '10.36.240.59', 'Type' => 'OctetString', 'Value' => ' 84 B1 E4 70 C7 D9', ), 5 => array ( 'OID' => '10.36.240.60', 'Type' => 'OctetString', 'Value' => ' 6C 7E 67 41 27 C3', ), 6 => array ( 'OID' => '10.36.240.67', 'Type' => 'OctetString', 'Value' => ' CE B9 5E 32 17 61', ), ); That's the hard part done. Now it's just a matter of looping through one array and looking for matches in the other.
    1 point
  2. Pro tip: When asking for the output of var_export, we don't want an image of it. We want you to copy/paste it into a code block so we can copy/paste it into an editor and use it to help you debug the code. Posting an image is not useful and a great way to get people to ignore your thread. Second tip, if you want to work with individual words, you should probably be storing them individually in a their own table, not as a comma separated list in your links table. Then getting your unique list of words would be a simple select distinct query.
    1 point
This leaderboard is set to New York/GMT-04:00
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.