In this way, the 01 string and the 01 string _ PHP Tutorial are used.

Source: Internet
Author: User
In this way, the 01 string is used, and the 01 string is used. In this way, I used 01 strings and 01 strings to share some interesting things with you. How do you use 01 strings and 01 strings to record a age group from a few minor issues?

When I was doing something today, I found a few interesting things and wrote them down to share them with you. Starting with a few minor issues

How do you record a person's age group ~ 70 or something like that?

You may say it is very simple. use two fields: start => start age, end => end age, or use the format of start | end in one field, separate them with a non-number in the middle, or use start | start-end. haha, there are many methods, but if you want to upgrade, you need to represent 10 ~ 20, 25, 29 ~ What do you mean by age 40? Of course, you can also use strings for representation, for example, 10-20 | 25 | 29-40. you can set some rules for representation. but can this representation be optimized? the answer is yes.

The 01 string can be used to represent the non-repeating age ranges. the default value is 100 0, indicating 1 ~ The age of 100. if it is 1, it indicates that the age exists. if it is 0, it indicates that the age does not exist. For better description, 10 zeros are used here, which indicates 1 ~ 10 years old, so:

0111111000 => 2 ~ 7 years old

0110111010 => 2 ~ 3. 5 ~ 7 or 9 years old

Haha, is it very convenient to express it, and it is easy to understand, of course, this also has its shortcomings, it is very convenient to express, but it is really inconvenient to use, it needs to be calculated.

How do I randomly select numbers from 1, 2, 3,..., 199, and 200?

Of course, there are many ways to use this method. for example, each number is represented by a string and separated by non-digits, such as: 1 | 5 | 100 | 199. I want to talk about this, which is represented by a 01 string, just like 1 ~ above ~ 200. select a part of this question. I can use a string of 200 positions. Each position is 0 or 1, and each position is the corresponding number. in this case, then, the information is represented as a 01 string. Still follow 0 ~ 10. example

0111111000 => 2, 3, 4, 5, 6, and 7

0110111010 => 2, 3, 5, 6, 7, 9

Of course, some people may say that the data I want to represent is not continuous, for example

1926, 19658, 12, 5638, 8975, 965, 369, 5126, 5698, 14556

The numbers above are very small and irregular, we want to indicate that the total number of 10 will not use the maximum number of positions in them (for example, 19658 0 here). of course not. in this case, you can use ING, the ing relationship is as follows:

1 => 1926,2 => 19658,3 => 12,4 => 5638,5 => 8975,6 => 965,7 => 369,8 => 5126,9 => 5698,10 => 14556

In this case, you can use the following 01 string to indicate the 1926, 12, and 5698 selections:


You may also find that this can also save traffic. when the two sides interact, we establish a ing relationship and do not need to transmit real data during network transmission, you only need to pass the corresponding 01 string.

Of course, this can also represent a lot of things. for example, I divide the time of a day into 1 segment for less than 5 minutes, a total of 288 segments. at this time, I randomly select some 5-minute segments from here, it is not good to use 288 01 strings of their own length, haha.

In some cases, this 01 string representation is quite desirable, and sometimes it will save traffic.

The copyright of this article is owned by the author iforever (, without the author's consent to prohibit any form of Reprint, Post reprinted article must be in the obvious position of the article page to give the author and the original article connection.

When I was doing something today, I found a few interesting things and wrote them down to share them with you. How do you record an age group from a few small issues...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.