I have a form, which has an upload ($_FILES[‘watch_photo’]) field. I have looked around and came to put this function together. It basically takes all relevant information so it is re-usable in the future, it will return an array of the $pid, and URL of the file, when it is done. The problem is th…
Tag: php
Delete html elements with php
I was wondering if I had an HTML page, how would I delete an element with php, by the name or id of it. so I could have HTML code like this
…
Count occurrences of a specific value in multidimensional array
Let’s say I have a multidimensional array like this: How would I be able to count how many times the value “Thing1” occurs in the multidimensional array? Answer Try this : Output : It gives the occurrence of each value. ie : Thing1 occurs 2 times. EDIT : As per OP’s comment : “Wh…
Symfony2 / Twig – getting array from dynamic array key
In PHP I would do this: foreach( $array as $key => $value ) { echo $another_array[$key]; } I can’t see how to do that in Twig (in Symfony2). I’ve tried various things, but this would seem …
Twig tag include vs function include
Twig’s documentation for tag include looks very similar to that of function include. Tag include: Function include: Can somebody point out in what circumstances, one is preferred over the other? Thanks! Answer {{ include() }} Was introduce in Symfony 2.2: Using a function allows you to do whatever you w…
Track how long a user stays on a page?
How can I track how long a user stays on a page before they request another or simply leave the site? Basically, I want to do a check, if a user stays on the page for 20 minutes or longer, then do something. I believe this would require php and javascript, but I am not exactly sure how to accomplish
OpenSSL not working on Windows, errors 0x02001003 0x2006D080 0x0E064002
Problem: OpenSSL is not working in my Windows environment. OpenSSL repeatedly reports errors 0x02001003, 0x2006D080 and 0x0E064002. Environment: What I’ve Attempted: Installation Instructions http://www.php.net/manual/en/openssl.installation.php PHP.ini extension=php_openssl.dll Openssl.cnf E:wampphpext…
How to use a 32bit integer on a 64bit installation of PHP?
I run into a problem on my code when moved to production because the production server is 32bit while my development machine is 64bit (I’m running Kubuntu 12.04 64bit). My question is. Is it possible to force an int to be 32bit without installing the 23bit version of PHP? Either that or a library that a…
listing files in folder showing index.php
I have this code, but it is showing the index.php itself How can I filter *.php files? Also is there a way to sort them by modification or creation time? Answer Here’s another that uses ksort or krsort functions (tested). (See comments in code.)
new mysqli(): how to intercept an ‘unable to connect’ error?
I’m doing this (yes, I’m using wrong connection data, it’s to force a connection error ) try { $connection = new mysqli(‘localhost’, ‘my_user’, ‘my_password’, ‘my_db’) ; } catch (Exception $e ) { …