How to print subscript using PHP Array

Source: Internet
Author: User
Tags php foreach

When learning PHP arrays, you may encounter many problems. Here we will introduce the solutions to the PHP array problems, and share them with you here. I started learning php. It has always been subjective that programming refers to writing applications in languages such as C, C ++. Web pages are always far-fetched. However, as a system administrator, if the website to be maintained is php, it is not enough to solve the system problem. To solve the problem, you still need to understand some php syntax.

So I secretly read php. During the learning process, php can also write scripts. Isn't that the best of both worlds? I only learned to write scripts in php for system management, so that I can be familiar with php syntax and modify some webpages as necessary. I don't know if I am the first person to use php scripts for system management. Hey hey, it's King to solve the problem.

Because of the workflow, after my colleagues write something, I need to update it to the server, and then my colleagues can see the effect again. There is no problem with this operation. However, for my colleagues, it is always "troublesome" to modify some things each time and I will feel uncomfortable. For me, I wrote a script for what my colleagues asked me to do to save trouble. When he asked me to update the script, I connected the server and directly executed the script.

So I was wondering: how can I let my colleagues do this without passing through me? It is unrealistic to open permissions on the server, because the smaller the Server Management permission, the better. When the Department boss proposed to write a page for his colleagues to do this on their own, I said that I already had this idea, but when the process was complete, I would not write the button clicked on the page. The boss said, This is simple, so there are three, five, two, and one with only one button. After you click it, you can write the output page of the execution result. In addition, this button can be clicked for unlimited times. This saves the trouble of accessing this page again each time. What do you guess when I give it to my colleagues? My colleague said with excitement: "Your small innovation really benefits all mankind !" Haha, even though I didn't say anything, I was happy. This is also a small incentive for php beginners. Come on!

I want to share with you how php prints the array subscript. When I see the php foreach function, I think it is a combination of perl foreach, but when I open a file and output it, I want to print the labels of each row. Perl has more than N built-in functions. You can use $. To implement this function. Cannot php be implemented? After searching for half a day, I asked a few friends who wrote php to define a variable in advance and print the variable. It seems that there is no way, So continue to look at the syntax. When you see a two-dimensional array. One time I accidentally printed a one-dimensional array in two-dimensional array format, so I found this secret! Figure:

498) this. width = 498; 'onmousewheel = 'javascript: return big (this) 'onclick = 'window. open ("http://blog.php100.com/viewpic.php? Refimg = "+ this. src) 'alt = PHP array src =" http://www.bkjia.com/uploadfile/2013/0904/20130904094734447.jpg "border = 0>


Needless to say, create a PHP array consisting of ten digits and then output the result.

498) this. width = 498; 'onmousewheel = 'javascript: return big (this) 'onclick = 'window. open ("http://blog.php100.com/viewpic.php? Refimg = "+ this. src) 'alt = array subscript src =" http://www.bkjia.com/uploadfile/2013/0904/20130904094734660.jpg "border = 0>

Is the execution result displayed? Is the array subscript correctly printed? It seems that php is also very powerful. This is what we share today. It's not a small dessert. At best, it's just a few minutes :)


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.