PHP small white, array value problem!

Source: Internet
Author: User
The number of levels is this: (picking up a bunch of data from a lot of them, actually I want to take all the data out and echo into the window)
[+] = Array
(
[OPTION_ID] = 30
[Option_name] = Att_type
[Option_value] = Rar,zip,gif,jpg,jpeg,png,txt,pdf,docx,doc
)


The goal I'm going to achieve is to print out rar,zip,gif,jpg,jpeg,png,txt,pdf,docx,doc when I echo Option_name's value arr_type (that is, the direct echo $arr _type).
Now know to use the loop to assign value, but can only use echo $option _name to fetch att_type This value, cannot echo $att _type to take Rar,zip,gif,jpg,jpeg,png,txt,pdf,docx,doc. God help me write a piece of code to achieve my idea, little white help AH!!!!!!


Reply to discussion (solution)

The great God came to save me ...

There is the wrong place, all the arr_type are wrong, it should be att_type

The great God, come and save me ....

It's hard to help without putting the code out.

It's hard to help without putting the code out.


The code is very simple, that is, first select out from the database, put in an array, and then print_r out after that.
$arr = $this->setting_model->get_setting ();//$query = $this->db->get (' options '); return $query Result_array ();
$this->load->p ($arr);d ie;

The database seems to have nothing to do with it, I won't post it.

$this->load->p ()//public function p () {echo '

;p Rint_r ($arr); Echo '
';}

But your demand is too exotic, too bizarre.

$a = Array (        ' option_id ' + = ' option_name ' = '            att_type '            ,            ' option_value ' = > ' Rar,zip,gif,jpg,jpeg,png,txt,pdf,docx,doc ',        ), foreach ($a as $r) {  ${$r [' option_name '}} = $r [' Option_ Value '];  echo $att _type;}
Rar,zip,gif,jpg,jpeg,png,txt,pdf,docx,doc

I don't know what that means.

$arr =  Array    (' option_id ' = ' = ',            ' option_name ' = ' att_type ',            ' option_value ' = ' rar ') , Zip,gif,jpg,jpeg,png,txt,pdf,docx,doc '    ), $a [$arr [' option_name ']] = $arr [' Option_value '];extract ($a); var_ Dump ($att _type);

But your demand is too exotic, too bizarre.

$a = Array (        ' option_id ' + = ' option_name ' = '            att_type '            ,            ' option_value ' = > ' Rar,zip,gif,jpg,jpeg,png,txt,pdf,docx,doc ',        ), foreach ($a as $r) {  ${$r [' option_name '}} = $r [' Option_ Value '];  echo $att _type;}
Rar,zip,gif,jpg,jpeg,png,txt,pdf,docx,doc


This is definitely not going to be an error, undefined att_type.

I don't know what that means.

$arr =  Array    (' option_id ' = ' = ',            ' option_name ' = ' att_type ',            ' option_value ' = ' rar ') , Zip,gif,jpg,jpeg,png,txt,pdf,docx,doc '    ), $a [$arr [' option_name ']] = $arr [' Option_value '];extract ($a); var_ Dump ($att _type);



Error, undefined option_name,option_value ... Wait, a lot (Undefined Index:option_value)

Is it? Take it for granted?!
I'm running out of results.

I know I'm going to use the Extract function, which is like assigning the value of name to value

Is it? Take it for granted?!
I'm running out of results.


Take a picture of your results, how can I run the error?

But your demand is too exotic, too bizarre.

$a = Array (        ' option_id ' + = ' option_name ' = '            att_type '            ,            ' option_value ' = > ' Rar,zip,gif,jpg,jpeg,png,txt,pdf,docx,doc ',        ), foreach ($a as $r) {  ${$r [' option_name '}} = $r [' Option_ Value '];  echo $att _type;}
Rar,zip,gif,jpg,jpeg,png,txt,pdf,docx,doc



I am also self-made, do not understand ${$r [' option_name ']} = $r [' Option_value '], this sentence, so change to $r [' option_name ']= $r [' option_value ']; Excuse me. This will solve, but also trouble to ask, ${$r [' option_name ']} = $r [' Option_value ']; I really can't read it.

For the sake of fairness, I'm showing you in the online editor of the Code Valley.

Read the variable variables section in the manual

Read the variable variables section in the manual



The great God is out of the picture Again!!!

In order to use the variable variable name of the array, you need to solve a ambiguity problem. That is, if you write $ $a [1], the parser needs to know whether you mean to use $a[1] as a variable, or to use the $ $a as a variable, [1] to refer to the index of the variable. The syntax for solving this ambiguity is: The first case uses ${$a [1]}, and the second case uses ${$a}[1].

Thank you, great gods!!! Learned the

  • 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.