Skip to content

Best way to clear a PHP array’s values

Which is more efficient for clearing all values in an array? The first one would require me to use that function each time in the loop of the second example. foreach ($array as $i => $value) { …

php email headers with MIME-Version: 1.0

I have these lines of code: I need the MIME type because I am using file_get_contents for an html file, my problem is under the headers it displays as “email@domain.comMIME-Version:1.0” and I want it just to say “email@domain.com” how do I take out the MIME type in the from displaying …

checking memory_limit in PHP

I’m need to check if memory_limit is at least 64M in my script installer. This is just part of PHP code that should work, but probably due to this “M” it’s not reading properly the value. How to fix this ? Answer Try to convert the value first (eg: 64M -> 64 * 1024 * 1024). After th…

Install fileinfo php extension

As the fileinfo is moved from PECL to PHP. What is the best way to install it through WHM or putty.? I tried following command: and received following error: WARNING: “pear/Fileinfo” is deprecated in favor of “channel://php-src/ext/fileinfo/in php sources “WARNING: channel “pear.…

DQL many to many and count

I’m using Symfony 2 with Doctrine, and I’ve got two entities joined in a many to many association. Let’s say I have two entities: User and Group, and the related tables on db are users, groups and …

Censor emails with PHP

I’m using this simple code: And i should get as output, something like ***@li.com; while i get ***@ I can’t debug it, i don’t know how what’s wrong. So the solution is I had to add () to make a group. Answer you need to create a group by adding (), and BTW it’s gonna be $1: also …

NetBeans auto-completion from included file not working?

I have a file named config.php, and i have other files includes config.php. When editing one of files, I use an object from config.php and it autocompletes name of the object. But, when i try to see functions or variables of this object (with ->), there is no auto-completion. Is there any way to make it wo…