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) { …
How to truncate a string in PHP to the sentence closest to a certain number of characters?
I want to truncate/shorten my string to the sentence closest to a ceratain number of characters. I have a working function, but my function truncate to the word closest to a certaion number of …
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…
Get the Selected value from the Drop down box in PHP
I am populating a Drop Down Box using the following code. get_all_catalogs(); foreach($array_all_catalogs as $array_catalog){…
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.…
Copy an image and preserve its EXIF/IPTC data with PHP imageCreateFromJpeg?
I having some problems with an image that has EXIF/IPTC data stored in it. When I use imageCreateFromJpeg (to rotate/crop or etc) the newly stored file doesn’t preserve the EXIF/IPTC data. My current code looks like this: Am I doing something wrong? Answer You aren’t doing anything wrong, but GD d…
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…