Skip to content

smarty replace line breaks

At the time of writing this, the smarty.net website appears to be down. Anyway, how do I replace line breaks with a space in a smarty variable? Is it something like this {$var|regex_replace:'[\r\n]…

php pchart pie chart problem with 0 value

I have a problem with my pie chart when I have 0 values $MyData->addPoints(array(10,20,20,15,23),”Data”); This works fine and converts to percentages across a pie chart however if any of these values are 0 which could happen as I’m dealing with counts and these are really variables in my …

socket connection code of php

I am writing a simple php socket code. Here is my code <?php $address="127.0.0.1"; $port=9875; echo "I am here"; if(false==($socket= socket_create(AF_INET,SOCK_STREAM, SOL_TCP))…

Pretty-Printing JSON with PHP

I’m building a PHP script that feeds JSON data to another script. My script builds data into a large associative array, and then outputs the data using json_encode. Here is an example script: The above code yields the following output: This is great if you have a small amount of data, but I’d pref…

PHP XSS sanitization

Questions: What are the best safe1(), safe2(), safe3(), and safe4() functions to avoid XSS for UTF8 encoded pages? Is it also safe in all browsers (specifically IE6)? . Many people say the absolute best that can be done is: . . There are a hell of a lot of posts about PHP and XSS. Most just say “use HTM…

PHPExcel very slow – ways to improve?

I am generating reports in .xlsx using PHPExcel. It was okay in the initial testing stages with small data sets (tens of rows, 3 sheets), but now when using it on a real production data with over 500 rows in each sheet, it becomes incredibly slow. 48 seconds to generate a file, and when running a report that …