Category Archives: PHP Solutions

Setting Timeout Value for file_get_contents in PHP

Sometimes you need to avoid using cURL for getting external web content for any reasons. You’re lucky that PHP has some built-in functions that allow you to get data from the Web without cURL. But if you are using default values, there is no option to set the timeout for a operation and it’s sometimes annoying. In order… Read More »

How to Open Links in a New Tab in Hesk 2.5.2

If you have used Hesk before, you must have mentioned that all links that were posted by users at the time of ticlet creation/reply were opening in new tabs. If you decide to update to 2.5.2 (I was using version 2.3 before), you will notice that all links will be opening in the current tab. If you want… Read More »

How to Show Only Duplicate Values From an Array With PHP

If you have an array with duplicate values, sometimes you might need to show only non-unique elements. Here is a short code in PHP that will allow you to do this. <? $arr=array_map(“trim”, file(“file.txt”)); $nonuniq=array_unique(array_diff_assoc($arr, array_unique($arr))); ?> This will return unique array of duplicates. If you need to show all duplicated values, use this code. <? $arr=array_map(“trim”, file(“file.txt”));… Read More »

How to Reset the Array of Mail Recipients using PHPMailer

Today I had to fix a script that sends an e-mail using PHPMailer. Here is the intital code: $mail->From = “lampdocs@gmail.com”; $mail->FromName = “Lampdocs.com”; $mail->AddAddress(“test@lampdocs.com”); $mail->AddReplyTo($webmaster_email, “Lampdocs.com”); $mail->WordWrap = 70; // set word wrap $mail->IsHTML(true); // send as HTML $mail->Subject = “Order from New Paypal Address”; $mail->Body = $milo; //HTML Body $mail->Send(); I had to send 2 different… Read More »

PHP: strtolower for Russian and Cyrillic

If you need to work with Russian text in PHP, you may notice that functions that are related to CaSe are not working as expected. I mean strtolower, strtouper, ucwords, and so on. In order to get what you need I suggest to use mb_convert functions. Here is the example: You can check reference table for functions, I… Read More »