The correct way to read a data file into an array

Just reading the file into an array, one line per element, is trivial: Now the lines of the file are in the array @lines. If you want to make sure there is error handling for open and close, do something like this (in the snipped below, we open the file in UTF-8 mode, too):

JQuery Number Formatting

I would recommend looking at this article on how to use javascript to handle basic formatting: source: http://www.mredkj.com/javascript/numberFormat.html While jQuery can make your life easier in a million different ways I would say it’s overkill for this. Keep in mind that jQuery can be fairly large and your user’s browser needs to download it when you use it … Read more

Back to previous page with header( “Location: ” ); in PHP

try: Note that this may not work with secure pages (HTTPS) and it’s a pretty bad idea overall as the header can be hijacked, sending the user to some other destination. The header may not even be sent by the browser. Ideally, you will want to either: Append the return address to the request as … Read more

Categories php

Grep only the first match and stop

-m 1 means return the first match in any given file. But it will still continue to search in other files. Also, if there are two or more matched in the same line, all of them will be displayed. You can use head -1 to solve this problem: explanation of each grep option:

How can I set size of a button?

The following bit of code does what you ask for. Just make sure that you assign enough space so that the text on the button becomes visible The X and Y (two first parameters of the GridLayout constructor) specify the number of rows and columns in the grid (respectively). You may leave one of them … Read more