Ask a question about PHP array format again, please.

Source: Internet
Author: User
Thanks for the problem with the previous array xuzuning help me answer, I want to ask another, if I put the table type value in the array this can also do?





The following array is implemented through the table above

Array (  [classname] = Array (            [0]=>            [1]=> Wedding service            [2]=> mechanical Equipment            [3]=> Hospital Medical            [4]=> Lighting            [5]=> Education Training            [6]=> Chemical coating            [7]=> Beauty Fitness [8]=> food            [9]=> Car service            ) [Layout] = Array (            [0]=>            [1]=> General            [2]=> Two column            [3]=> three columns            [4]=> grid            ))


Reply to discussion (solution)

According to my writing, $res is the format you want now.
Because your post wants an array of subscripts, there will be
$res = Array_values ($res);

$classname = "SELECT * from table where type= ' classname '", $layout = "SELECT * from table where type= ' layout '";

According to my writing, $res is the format you want now.
Because your post wants an array of subscripts, there will be
$res = Array_values ($res);




Xuzuning I just tried to come out, thank you, that is what you said with $res this format, there is a problem, if I want to output when the "unlimited" two words to replace the empty value to how to operate?

In all of your previous descriptions, there is no "unlimited" two characters


In all of your previous descriptions, there is no "unlimited" two characters



Sorry, just found that the uploaded data are old. The Typevalue value for type=0 is "unlimited". Or is that OK? is how to implement the Typevalue value of the corresponding row as a null value when type=0 in the result of an array output

while ($row = Mysql_fetch_assoc ($rs)) {
if ($row [' typeid '] = = 0) $row [' typevalue '] = ';
$res [$row [' type ']][] = $row [' Typevalue '];
}

while ($row = Mysql_fetch_assoc ($rs)) {
if ($row [' typeid '] = = 0) $row [' typevalue '] = ';
$res [$row [' type ']][] = $row [' Typevalue '];
}



Okay, thank you so much.
  • 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.