Skip to content

Tag: php

PHP regular expression – filter number only

I know this might sound as really dummy question, but I’m trying to ensure that the provided string is of a number / decimal format to use it later on with PHP’s number_format() function. How would I do it – say someone is typing 15:00 into the text field – what regular expression and …

How do I display a wordpress page content?

I know this is really simple but it just isn’t coming to me for some reason and google isn’t helping me today. I want to output the pages content, how do I do that? I thought it was this: Answer @Marc B Thanks for the comment. Helped me discover this:

Call method by string?

This doesn’t work: Is the only possibility to use call_user_func();? Answer Try: Be sure to check if the action is allowed and it is callable

z-Scores(standard deviation and mean) in PHP

I am trying to calculate Z-scores using PHP. Essentially, I am looking for the most efficient way to calculate the mean and standard deviation of a data set (PHP array). Any suggestions on how to do this in PHP? I am trying to do this in the smallest number of steps. Answer to calculate the mean you can do: s…

Do comments make the code run slower?

I heard that a heavily commented script runs slightly slower than a non-commented one. Is it true? Did anyone test this? (like how much slower is it in percentages) Answer Commenting will not affect the script execution time in normal case. But the number of lines you write in your code affect the parser to r…

PHP PDO extension not working on IIS

I have a script which uses __autoload() to load classes (stupid, I know, this is old code I used to use for fun / testing), and it seems to be trying to autoload PDO. This leads me to believe that it’s not finding the PDO class it should be. I have checked php.ini and php_pdo.dll is enabled, along with …

Excel output with codeigniter

I’m trying to get a report from my codeigniter project in excel, but I am at a complete loss on how to do it. It already works well, just would like the output in excel rather then a page. Any tips/pointers/explanations? thanks! Answer I’ll refer you to this wiki article from the codeIgniter site,…