Jump to content
php.lv forumi

array_merge


goma smile

Recommended Posts

Palīziet lūdzu iedomājieties 2 tabulas

 

vienā ir lauks ar implodētiem skaitļiem un otrā ir skaitļi ar implodetiem skaitļiem, piemēram:

 

 

kkas 1,2,3,4,5,6 un citā tabulā tādā pašā stilā 1,2,3,7,8,9,11 un kā var izvilkt sarakstu ar tikai unikāliem skaitļiem pēc salīdzināšanas starp abām tabulām

 

1,2,3,4,5,6,7,8,9,11 - kaut kā tā

Link to comment
Share on other sites

  • 3 weeks later...

array_unique(

    array_merge(

        array(1,2,3,4,5,6),

        array(1,2,3,7,8,9,11)

    )

)

 

 

Iedomājieties ka man ģenerējās kkas šāds kā var apvienot lai nosaka unikālās vērtības

    [0] => Array        (            [0] => 110            [1] => 122            [2] => 123        )    [1] => Array        (            [0] => 112        )    [2] => Array        (            [0] => 122        )    [3] => 110    [4] => 120    [5] => 130
Link to comment
Share on other sites

Hmm, saliec abus listus kopā un uztaisi par setu. Datu tipi un to īpašības, jēj!

 

Pseido-kods:

 

~~~

>>> print(set([1, 2, 2, 3] + [3, 1]))

{1, 2, 3}

~~~

Edited by daGrevis
Link to comment
Share on other sites

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.   Paste as plain text instead

  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.

Loading...
×
×
  • Create New...