How to convert a default empty string of the data table field demand_praiseid type varchar to an array

Source: Internet
Author: User
{Code ...} one of my demands for release is that no one is saving it. when I like it, I will retrieve the required demand_praiseid field and convert it to an array. I will save the uid to an array and then save the array in the converted json field. I don't know if I did this one day...
// Add the likes public function addPraisePeople ($ uid, $ deman_id) {$ demanid ['demand _ id'] = $ deman_id; $ m = D ('demo '); $ praiseid = $ m-> where ($ demandId)-> getField ('demand _ praiseid ');}

One of my demands for release is that no one is saving it. when I like it, I will retrieve the required demand_praiseid field and convert it to an array. I will save the uid to an array and then save the array in the converted json field.

I don't know if I have made this project too complicated.

Reply content:
// Add the likes public function addPraisePeople ($ uid, $ deman_id) {$ demanid ['demand _ id'] = $ deman_id; $ m = D ('demo '); $ praiseid = $ m-> where ($ demandId)-> getField ('demand _ praiseid ');}

One of my demands for release is that no one is saving it. when I like it, I will retrieve the required demand_praiseid field and convert it to an array. I will save the uid to an array and then save the array in the converted json field.

I don't know if I have made this project too complicated.

First, after understanding your question, you should ask:
There is a data table field of the varchar type. after you obtain the value of this field using PHP, how can you convert the value of this field into an array?
Second, if you want to convert the content of demand_praiseid into an array, you have to convert it according to your demand_praiseid structure.
PHP has a function that converts a string to an array:
Explode (separator, string, limit)
Parameter description: separator: required. Specifies where to split the string.
String: required. The string to be split.
Limit: Optional. Specifies the number of returned array elements. Possible values: greater than 0-returns an array containing up to limit elements less than 0-returns an array containing all elements except the last-limit elements 0-returns an array containing one element
I hope to help you, but I don't seem to quite understand your needs.

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.