mister5317
-
Posts
19 -
Joined
-
Last visited
Never
Posts posted by mister5317
-
-
I found it a fun learning experience to make something as simple as "HELLO WORLD!" into a difficult process.
I obfuscated my PHP below to just echo "HELLO WORLD!". Anyone else have a better example to echo "HELLO WORLD!"?
<?php // Output = HELLO WORLD! function __e($_){echo$_; }function __($_){__e(chr ($_));}function _a(){$__ =func_get_args();foreach ($__ as$k=>$v)$a[$k]=$v; return$a;}foreach(_a(7,4 ,+11,11,14,-33,22,14,17, 11,3,-32)as$k=>$v){__(65 +$v);}
Give it a shot, it more difficult to think of creative ways to make something out of the box like this.
-
I think I have figured it out!
<?php function roundTime($timestamp, $precision = 15) { $timestamp = strtotime($timestamp); $precision = 60 * $precision; return date('Y-m-d H:i:s', round($timestamp / $precision) * $precision); } // 2009-06-29 10:45:00 echo roundTime('2009-06-29 10:48:13'); ?>
-
I have timestamps in a database that are from the creation time of the records. These timestamps are something like 2009-06-29 08:54:32.
In this case, I would like to round this timestamp to the nearest 15 minute increment (00:00, 00:15, 00:30, or 00:45) so the end result for 2009-06-29 08:54:32 would be 2009-06-29 09:00:00.
If the time stamp was 2009-06-29 09:07:17, then the end result would still be 2009-06-29 09:00:00.
Another option, if possible, would be to always round up. Maybe have an argument in the function to round to nearest or to round up/down?
Can someone help me build a function to do this? It would be greatly appreciated!
Thank you!
-
I have an array of hexadecimal color codes:
Array ( [0] => 2060A0 [1] => 204080 [2] => 206080 [3] => 000000 [4] => A0A0A0 [5] => C0C0C0 [6] => 808080 [7] => E0E0E0 [8] => 404040 [9] => 80A0A0 [10] => 202020 [11] => 002020 )
I would like to sort the array by color. I tried a natsort() and that didn't work the way I would have liked.
Does anyone have any ideas on how to accomplish this?
Thanks!
-
I also tried the instructions here: http://discussions.apple.com/message.jspa?messageID=8418099#8418099
I got to the configure command and had this problem:
checking for MySQL support for PDO... yes, shared checking for mysql_config... /usr/local/mysql/bin/mysql_config checking for mysql_query in -lmysqlclient... no configure: error: mysql_query missing!?
-
I wish. There is macports.
How would I go about reinstalling Apache, PHP and MySQL without junking up my system or breaking the default install?
-
Thank you! Can you help me debug what I have found?
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/extensions/no-debug-non-zts-20060613/pdo_mysql.so' - (null) in Unknown on line 0
I also found this from a few days ago, but I haven't seen it in the logs recently.
dyld: Library not loaded: /usr/local/mysql/lib/libmysqlclient.16.dylib Referenced from: /usr/lib/php/extensions/no-debug-non-zts-20060613/pdo_mysql.so Reason: no suitable image found. Did find: /usr/local/mysql/lib/libmysqlclient.16.dylib: mach-o, but wrong architecture
Any ideas?
-
Any ideas of where/what logs I should be looking at? What am I looking for?
-
I have confirmed that I am editing the correct php.ini file. I also have the GD module installed. Once I commented the extension line for that module I no longer saw GD support with php -m or phpinfo();. After uncommenting it, I saw it in both locations again.
-
Hmmm, I am editing the php.ini file listed on the info page as the "Loaded Configuration File".
-
If I comment out the extension line, rerun php -m, pdo_mysql is no longer there. Once I uncomment the line again, I see pdo_mysql in php -m, but not with phpinfo();.
-
Yes, it is uncommented.
-
I am running Apache/PHP on Leopard with the base install provided by Apple. I need support for pdo_mysql so I followed the directions at http://starfog.com/node/52. When I run php -m from the command line, I see that both PDO and pdo_mysql are listed. If I check my phpinfo page, I do not see pdo_mysql anywhere. What can I do to get pdo_mysql support on Leopard?
Thanks!
-
<?php $string = 'The quick brown fox jumped over the lazy dog.'; echo substr($string, 0, 25); // 'The quick brown fox jumpe' ?>
The last parameter, 25, is the number of characters to print.
See http://us2.php.net/substr for more information.
-
<?php $test = 'Paths.Images.Icons'; $out = array(); foreach (array_reverse(explode('.',$test)) as $v) $out = array($v => $out); print_r($out); ?>
Wow! That is genus and so simple!
Also, I compared the two slightly different functions, see below.
<?php // Sasa's Function function strToNestedArray($string) { $out = array(); foreach (array_reverse(explode('.',$string)) as $v) $out = array($v => $out); return $out; } // uniflare Function function str_to_nested_array($string) { $rVerse = array_reverse(explode('.',$string)); foreach ($rVerse as $v) $out = array($v => $out); return $out; } $str = "path.to.something.that.is.really.neat"; echo "100k call * 10 benchmarking: <br/><br/>"; echo "Sasa's Test<br/>"; for ($y = 0; $y < 10; $y++) { $start = microtime(true); for ($x = 0; $x < 100000; $x++) { $structure = strToNestedArray($str); } $time = microtime(true) - $start; echo $time . "<br/>"; } echo "<br/>uniflare 's Test<br/>"; for ($y = 0; $y < 10; $y++) { $start = microtime(true); for ($x = 0; $x < 100000; $x++) { $array = str_to_nested_array($str); } $time = microtime(true) - $start; echo $time . "<br/>"; }
Here are the results:
100k call * 10 benchmarking:
Sasa's Test
0.581806898117
0.576666116714
0.580965995789
0.581721782684
0.580982923508
0.579081058502
0.579075813293
0.578878879547
0.578855037689
0.580253124237
uniflare's Test
0.655313968658
0.654915094376
0.655946016312
0.654715061188
0.655534029007
0.662548065186
0.647897958755
0.648191213608
0.6495449543
0.650224924088
I really appreciate everyone's help and snippets. Thanks everyone!
-
Sorry, one more question, is it possible to call the function with the only argument being the input string?
<?php $array = str_to_nested_array('Paths.Images.Icons'); ?>
-
That is perfect!
Can you please explain the code a little bit? I have never used a function within a function like this...
Thanks again!
-
I have a string that I need converted to a nested array. See code below:
// Input string $string = 'Paths.Images.Icons'; /* Need the following back: Array ( [Paths] => Array ( [images] => Array ( [icons] => Array ( ) ) ) ) */
I need a function that will parse the input string and generate a nested array based on the periods in the input string.
Can someone help me create a function to do this?
Thanks!
PHP Obfuscation
in Miscellaneous
Posted
Shoot, sorry, I don't see a place to move it...