php-general Digest 15 Jun 2011 15:37:50 -0000 Issue 7359 Topics (messages 313541 through 313549):
Re: Ftp upload
313541 by: admin.buskirkgraphics.com
313543 by: Melinda Smith
313545 by: Pete Ford
313547 by: Marc Guay
313548 by: Steve Staples
Re: Extracting data from exec() call
313542 by: Jim Lucas
Import symbol table into function' scope.
313544 by: äÍÉÔÒÉÊ óÔÅÐÁÎÏ×
Re: Convert a PDF to a PNG?
313546 by: Richard Quadling
PHP and Windows 7 g6-bit
313549 by: Byron Como
Administrivia:
To subscribe to the digest, e-mail:
[email protected]
To unsubscribe from the digest, e-mail:
[email protected]
To post to the list, e-mail:
[email protected]
----------------------------------------------------------------------
--- Begin Message ---LOL yeah. Since I can buy a 2 terabyte external hard drive and caddy for less than $300. At Best Buy. Richard L. Buskirk... -----Original Message----- From: Marc Guay [mailto:[email protected]] Sent: Tuesday, June 14, 2011 8:25 PM To: PHP General Subject: Re: [PHP] Ftp upload I bought a 1GB external hard drive for $1000. Did I just choke on my lunch? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---Marc, I've got a bridge to sell you... On Tue, Jun 14, 2011 at 6:03 PM, <[email protected]> wrote: > LOL yeah. > Since I can buy a 2 terabyte external hard drive and caddy for less than > $300. At Best Buy. > > Richard L. Buskirk... > > > -----Original Message----- > From: Marc Guay [mailto:[email protected]] > Sent: Tuesday, June 14, 2011 8:25 PM > To: PHP General > Subject: Re: [PHP] Ftp upload > > I bought a 1GB external hard drive for $1000. Did I just choke on my > lunch? > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >
--- End Message ---
--- Begin Message ---On 15/06/11 01:24, Marc Guay wrote:I bought a 1GB external hard drive for $1000. Did I just choke on my lunch?If that was about 20 years ago, then it would be fine! -- Peter Ford, Developer phone: 01580 893333 fax: 01580 893399 Justcroft International Ltd. www.justcroft.com Justcroft House, High Street, Staplehurst, Kent TN12 0AH United Kingdom Registered in England and Wales: 2297906 Registered office: Stag Gates House, 63/64 The Avenue, Southampton SO17 1XS
--- End Message ---
--- Begin Message ---> If that was about 20 years ago, then it would be fine! Would have been around 1992, good guesswork!
--- End Message ---
--- Begin Message ---On Wed, 2011-06-15 at 07:42 -0400, Marc Guay wrote: > > If that was about 20 years ago, then it would be fine! > > Would have been around 1992, good guesswork! > ugh, i feel old now (even though i am not)... 20 years ago is 1991... i got my car/motorcycle license in 1992 at the age of 16... -- Steve Staples Web Application Developer 519.258.2333 x8414
--- End Message ---
--- Begin Message ---On 6/14/2011 10:35 AM, Ashley M. Kirchner wrote: > > I'm trying to extract data coming from an exec() call. The exec() call is > performing an ncdump on a netCDF file: > > <?php > $filename = "mlab.20110101.cdf"; > exec("/usr/bin/ncdump -l 2048 -v wmax ".$filename, $output); > echo "---\n"; > print_r($output); > echo "---\n"; > ?> > > This is all fine, however the data comes in with extra information I don't > need, and the data I do need is in a long string format: > > Array > ( > [0] => netcdf mlab.20110101 { > [1] => dimensions: > [2] => time = UNLIMITED ; // (288 currently) > [3] => variables: > [4] => int base_time ; > [5] => int samp_secs ; > [6] => float lat ; > [7] => float lon ; > [8] => float alt ; > [9] => int station ; > [10] => float time_offset(time) ; > [11] => float tdry(time) ; > [12] => float rh(time) ; > [13] => float pres(time) ; > [14] => float cpres0(time) ; > [15] => float dp(time) ; > [16] => float wdir(time) ; > [17] => float wspd(time) ; > [18] => float wmax(time) ; > [19] => float wsdev(time) ; > [20] => float wchill(time) ; > [21] => float raina(time) ; > [22] => float raina24(time) ; > [23] => float bat(time) ; > [24] => data: > [25] => > [26] => wmax = 5, 5, 5, 5.4, 5.7, 5.1, 7.1, 6.1, 4.4, 9.5, 13.5, > 14.4, > 11.1, 9.6, 10.5, 10.6, 11.1, 10, 15.3, 17.2, 16.9, 16, 13.9, 16.7, 15.3, 18.3, > 17.2, 16.3, 15.9, 18.9, 17.7, 19.7, 19.7, 16.6, 16.4, 16, 14.6, 14.9, 14, > 16.7, > 18.3, 16.2, 18.4, 15.4, 15.3, 13.3, 14.8, 15.6, 15.1, 14.7, 13.8, 14.2, 18, > 16.7, 16.6, 15.6, 15.8, 17.6, 17.4, 20.3, 17.4, 21.3, 18.7, 16.7, 15.4, 17.5, > 17.3, 17.7, 20.4, 17.5, 16.8, 18.1, 15.9, 17.8, 17.3, 13.9, 16.2, 17.4, 19.8, > 17.5, 19, 20, 20.3, 20.4, 20.8, 21.6, 26.4, 23.1, 21.3, 19.9, 20.1, 21.1, > 22.1, > 22.5, 21.2, 20.2, 22.2, 21.6, 19.6, 21.1, 21.7, 21, 20.8, 23.7, 26.6, 21.2, > 23.8, 23.3, 23.5, 23.9, 21.4, 22.1, 23.5, 22.8, 23, 21.8, 22.2, 25.6, 21.9, > 22.8, 26.2, 24.2, 23.6, 25.5, 26.8, 25.6, 27.4, 24.5, 23.5, 22.1, 23.1, 25.5, > 22.5, 22.5, 23.8, 21.8, 22.6, 23.5, 24, 23, 22.3, 21.6, 23.6, 20.5, 21, 19.4, > 23.6, 19.2, 18, 19.2, 20.5, 19.3, 19.1, 20.4, 18, 17.8, 18.4, 19.4, 21, 18.3, > 20.4, 21.2, 22.1, 20.1, 17.3, 17.2, 17.6, 17.2, 19.9, 21, 20.6, 21.5, 23.8, > 25, > 24, 23.9, 23.5, 27.7, 21.1, 20.8, 20.1, 18.6, 21, 18.7, 19.9, 16.4, 16.3, > 17.3, > 11.8, 11.4, 15.2, 12.4, 14.2, 16.3, 21.6, 25, 19, 7.7, 9.7, 15.7, 7, 11.1, > 10.3, > 11.2, 14.8, 11.7, 5.5, 5.5, 5.5, 6.9, 7.6, 6.5, 6.4, 6.7, 6.7, 4.9, 5.1, 4.7, > 5.7, 5.5, 9.2, 6.2, 7.1, 7.7, 6.5, 5.5, 6, 6.4, 7, 6.2, 6.7, 4.7, 3.8, 9.2, > 8.1, > 7.6, 6.8, 6.3, 7.1, 10.5, 8, 9.9, 10.2, 12, 9.4, 14, 18, 11.9, 17.7, 20.9, > 18.8, > 17.4, 13.5, 13.8, 12.6, 5.5, 6.1, 6.6, 6.3, 6.3, 5.1, 7.7, 5.8, 5.4, 4.9, 4.5, > 4.9, 4.7, 5, 4.8, 4.5, 5.6, 5.9, 4.6, 5.7, 7.2, 6.1, 6.4, 5.4, 6.1, 5.6, 5.9, > 6.4, 9.5, 11.2, 15.8, 15, 13.6 ; > [27] => } > ) > > ncdump doesn't provide an option to suppress the header information, and > as > you can hopefully tell, the data I'm looking for is in one long string at key > position 26. > > How can I extract what I need from that (wmax) and have it as an array: > wmax > = array(5, 5, ...) > > This is only one variable. I will be pulling more variables out, and they > all come out the same way as above, as strings. The headers might change, so > I > can't simply say ignore the first 0-25 keys and expect what I need to be at > position 26. I need a reliable way of detecting where the data section > starts. > And I need to convert the strings into arrays for each data set. > > Suggestions? > Here is a one liner that assumes a lot print_r(explode(', ', substr($output[count($output)-2)], 7)); Now, if you want a little more error checking and forgiveness, try this <?php ### all your stuff here ### $wmax = null; # Loop it all... foreach ( $output AS $line ) { # check to see if line starts with what I'm searching for... if ( strpos($line, 'wmax = ') === 0 ) { # Found something, strip beginning of string and explode rest $wmax = explode(', ', substr($line, 7)); # Since I found it, I don't need to continue; drop out break; } } # See if I have an array() if ( is_array($wmax) ) { # We have an array, now see if it is populated at all if ( $cnt = count($wmax) ) { # Great, tell them how many values we found echo 'I found '.$cnt.' wmax values and here they are.'.PHP_EOL; # Show them the values print_r($wmax); } else { # Darn, our array was empty, lets tell them the bad news... echo 'no wmax values were set'; } } else { # Dang, I couldn't find the wmax line, better let them know! echo 'could not identify the wmax values returned'; } ?> Jim Lucas
--- End Message ---
--- Begin Message ---Hello, everybody. Consider the following code: class DB { public function query( $sql) { // ... some "magic" of DB querying } } class DBReader { public $DB;// instance of DB public function __call( $methodName, $args) { return call_user_func_array( array( $this, $methodName), $args); } protected function readSomething() { $sql ='SELECT ...'; $result =$this->DB->query( $sql); } protected function readSomethingElse() { // ... very similar to DBReader::readSomething() } // .... + other methods like DBReader::readSomething() } If you take a look at DBReader::readSomething(), you'll see that I am referencing database object and performing query via "$this->DB->query()". If you do a lot of database queries, your code becomes bloated with "$this->DB->..." and usually gets not so well readable (at least for me). Since I have a lot of methods, that are similar to DBReader::readSomething() (which perform DB queries), I would like to optimize readability of the DB querying code. Right now I would do it in the following way: // 1) reference database object inside the method $DB =$this->DB; // 2) do whatever I need with the DB $DB->query( $sql); $DB->numRows(); // ... or whatever This way the code looks nicer and is, in fact, shorter. So I wonder if there is any way to import scope (symbol table) into the method DBReader::readSomething()? By importing the variables into the function body, I would like to avoid the "1) reference database object inside the method" step so that $DB becomes instantly available: protected function readSomething() { $sql ='SELECT ...'; $result =$DB->query( $sql);// like this } AFAIK, there is no such call_user_func* function that would allow importing of symbol table into the called fn. What I would expect to be possible: public function __call( $methodName, $args) { $scope =array( 'DB' =>$this->DB); return call_user_func_array( array( $this, $methodName), $args, $scope);// note the $scope array, that is being passed here } The effect of such call to call_user_func_array() I would expect to be equivalent with same as regular call to call_user_func_array(), but with additional call to extract( $scope, EXTR_REFS) right at the top of the function's body. Does anybody have some ideas how I can get this working? If there is no way to get this working with current PHP feature set, then I would like to propose to extend call_user_func_array() to support $scope argument. What do you think about this? P.S.: don't ask why I don't just simply make DBReader::readSomething() to be public method. That's not the case. P.S.: a very similar scope importing technique I am using with the PHP template files I use in my web projects. As you know, include() is, literally, "injecting" code from the file into the current scope, thus making current symbol available to the included code: index.php: $x =5; $y =10; include("chart.php"); chart.php: echo $x .',' .$y; After processing index.php, the output would be "5,10". P.S.: closures are capable of importing scope via use() statement: $x =5; $y =10; $closure =function() use( $x, $y) { echo $x .',' .$y; }; $closure();// would give output "5,10" so I suppose that technically importing scope is not a big deal from the PHP internals perspective. Dmitry.
--- End Message ---
--- Begin Message ---On 15 June 2011 00:00, Tamara Temple <[email protected]> wrote: > > On Jun 14, 2011, at 5:48 PM, Brian Dunning wrote: > >> The PDFs are text only (white text on transparent background). I made them >> using the FPDF, which was tedious to set up but works great. I've since >> learned that I need PNG images, not PDFs. I know that I could rebuild them >> using GD, but it's a lot of strings of text wrapping and formatting and that >> would be the long, long way around. >> >> I've put in a request to see about getting ImageMagick/Ghostscript >> installed... see how that goes. > > Well there's one on me... I didn't even *know* you could covert a text PDF > to a PNG image.... > > The more you know <rainbow/> It is just a case of rasterizing the PDF to a "display" and encoding it to an image (or raw). Admittedly, all the PDFs I work with are essentially images as the source is a fax server. I use PDF2PNG as this provides the cleanest output mechanism I've found. But I didn't try GS which, theoretically, should be perfect. Once in a PNG file, I use commandline IMagick to add a "tag" to the top and the bottom of the fax (the bottom tag is rotated 180 degrees). The tag can then be read regardless of the orientation of the fax when the user scanned it. Processing several thousand faxes a day. For 6 years or so. A LOT of paper saved at our end. -- Richard Quadling Twitter : EE : Zend : PHPDoc @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea
--- End Message ---
--- Begin Message ---Does the precompiled windows binary work on win 7 64?
--- End Message ---
