Jump to content
php.lv forumi

between


goma smile

Recommended Posts

Labdien man ir tā ka 

 

ir divi skaitļi 1-1200 (Abi var būt mainīgi), un ir vēl 2. skaitļi 100-1000 arī var būt mainīgi, kā varētu viņu abus salīdzināt un pārbaudīt vai viņu abu range 2.slaitļi ir zem pirmā pāra...

 

 

vai 1-1200 range apņem 100-1000 range..

 

Kādam ir idejas

Link to comment
Share on other sites

Tas gadījumā nav kāds mājasdarbs?

/**
* Pārbauda vai diapazons $oneStart..$oneEnd pārklāj $twoStart..$twoEnd
* @return bool
*/
function between($oneStart, $oneEnd, $twoStart, $twoEnd) {
    return $oneStart <= $twoStart and $oneEnd >= $twoEnd;
}

between (1, 1200, 100, 1000); // atgriež true
between (120, 1200, 100, 1000); // atgriež false
between (1, 900, 100, 1000); // atgriež false
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...