Jump to content

Recommended Posts

I have this array:

 

$numberMaps = array(
'0011110001000010100000010100001000111100',
'0010000101000001111111110000000100000001',
'0100001110000101100010011001000101100001',
'0100001010000001100100011001000101101110',
'0001110000100100010001001111111100000100',
'1111001010100001101000011010000110011110',
'0011111001010001100100011001000110001110',
'1000000010000011100011001011000011000000',
'0110111010010001100100011001000101101110',
'0111000110001001100010011000101001111100'
);

 

I figure it would be easier to accomplish what I need to do by writing a simple php script rather than doing it by eye.. Basically I need to find out how short I can shorten those strings in the array so that they're still unique.

Link to comment
https://forums.phpfreaks.com/topic/161172-solved-comparing-elements-of-an-array/
Share on other sites

Nevermind, I solved it. Since just 8 numbers would be good enough (since it relates to 1 full loop somewhere else in my code).. I just did this:

 

$numberMaps = array(
'0011110001000010100000010100001000111100',
'0010000101000001111111110000000100000001',
'0100001110000101100010011001000101100001',
'0100001010000001100100011001000101101110',
'0001110000100100010001001111111100000100',
'1111001010100001101000011010000110011110',
'0011111001010001100100011001000110001110',
'1000000010000011100011001011000011000000',
'0110111010010001100100011001000101101110',
'0111000110001001100010011000101001111100'
);
for($i = 0;$i < count($numberMaps);$i++)
{
$newArr[] = substr($numberMaps[$i], 0, ;
}

for($i = 0;$i < count($newArr);$i++)
{
for($j = 0;$j < count($newArr)-1;$j++)
{
	if($newArr[$i] == $newArr[$j] && $j != $i)
	{
		echo 'Found a match..' . $i . ' and ' . $j;
	}
}
}

 

No matches.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.