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 …
Tag: php
PHP get the last 3 elements of an associative array while preserving the keys?
I have an array: How can I get the last 3 elements while preserving the keys? (the number of elements in the array may vary, so I cannot simply slice after the 2nd element) So the output would be: Answer If you want to preserve key, you can pass in true as the fourth argument:
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…
Any good PHP MySQL-compatible reporting frameworks out there? [closed]
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations. Closed 2 years ago. Improve this ques…
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,…
calling php file fron another php file while passing arguments
i need to call a php inside another php file and pass some arguments also. how can i do this?? i tried include(“http://…/myfile.php?file=$name”); but gives access denied. i read like v must not …