PHP WeChat public development notes (9) and php public development notes

Source: Internet
Author: User

PHP public development notes (9) and php public development notes
PHP public development notes Series
Date: 2014.9.9
 
The Mid-Autumn Festival holiday has not changed much except Saturday. Today, I went to work to complete the two established development goals: "Gossip" and "Memories". These two modules are also very simple and mainly involve database operations. Then you can reply in text format. Therefore, the database mainly stores the following fields: Article Title, article jump connection, and image link.

Sort notes:
When I write this note, I am catching up with the function. So I simply remember a few pieces of work at that time. Now the function is almost developed, so I will sort out the previous notes. At that time, it was easy to record the above statements.

This week is very idle. It should be said that I was idle since last week, or I will not have time to develop this public platform, so take the time to finish all the functions to be done before you go home, and sort out the functions later.

To create these two modules, you can create two data tables in apsaradb. Then we can use the random number to reply. Speaking of random numbers, I used a random number with seeds here to ensure random numbers are more random:



The time used for the call is used as the seed of the random number. This guarantees the randomness of the random number to the maximum extent.

I. Gossip

When replying to gossip information, I first obtain all the data rows of gossip information from the database, store them in a two-dimensional array, and then call the random number above to obtain a random array subscript, then obtain the data information of this row. In this way, the random reply is implemented:



The students said they wanted a mechanism to reply in sequence, that is, they could reply in the database order each time. On this basis, I made improvements, I .e., they randomly choose whether to reply in sequence or randomly. The following figure shows how to implement sequential reply:



The sequence has not been detected, and it is useless.
After the data information is obtained, it is replied in the form of text and text. This is mentioned before and will not be mentioned here.

Ii. Memories
This is also achieved by building a data table in the cloud data. However, I think, you can also recall gossip information. So I used the two data tables together. The train of thought is: get two-dimensional arrays of two data tables, gossip and recall from the database, and then combine the two-dimensional arrays for use. The rest is about the same as that of gossip.
Here we will talk about the merging of arrays in php. There are two ways to merge these functions: array_merge () and array_combine (). The differences between the two functions are also described on the Internet:
Array_combine can only be used for merging two arrays. The value of an array is used as the key of the new array? Is the value of the second array the value of the new array?
Array_merge can be used to merge multiple arrays. If two key names are the same, the key value of the key is the value corresponding to the last key name (the subsequent value overwrites the previous value ). If the array is a digital index, the key name will be re-indexed in a continuous manner.
So after reading these two introductions, I think we need to merge the two arrays in the array_merge mode, and then what should we do.
Php development Public Code text how to wrap

I also used php to develop public numbers. \ n is used. You should enclose the text in double quotation marks instead of single quotation marks.
Example: $ msg = "XXXXXXXX: \ n XXXXXXXXXXXX \ n XXXXXX ";

PHP development on the public platform cannot be replied

Here is a simple demo.

Download.csdn.net/detail/bjdgyc/5082453

Related Article

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: info-contact@alibabacloud.com 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.