The way I am doing my pagination now is as follow: =============== First I do the normal query, and get all the result back. After that I count the results, lets say 300. I do this with num_results …
Tag: php
Split a string array into pieces
Let’s say I have an array that store like this: How should I make the array[0] string split into piece by separated the “;”? Then I want to save them in array again, or display them out. How should I do it? Answer I would personally use the preg_split to get rid of that extra array element t…
I have 2 dates in PHP, how can I run a foreach loop to go through all of those days?
I’m starting with a date 2010-05-01 and ending with 2010-05-10. How can I iterate through all of those dates in PHP?
append php in jquery
I’m trying to dynamically create a div to show error messages using jquery. I’m able to use append() to create the HTML easily enough, but I need to call a php variable in order to display the content….
Base10 to base64 url shortening
I’m coding an url shortener function for a project in which I’m learning php, here is the code (btw I suppose that global here is not a good thing to do :P): The code is taken from this Wikipedia article and adapted to php. My problem is that when I pass a multiple of 64 to the function I get
Validate class/method names with regex
I’m currently working on an MVC Style framework for a company and for security reasons I need to make sure that the controller / method that’s passed via the Query String is valid chars to the RFC (which I can’t find). I need to be able to validate / sanitize class names according to what…
How do i save logs in php
How do i save logs in PHP? Is there any “magical” function available in php for doing so, or any library? Or should i have to fopen file everytime and dump in it? I want to save my logs in text file. Thanks in advance 🙂 Answer I wrote a simple class to do this. Maybe you’ll find it useful.…
Print string with a php variable in it
For you guys, I imagine this will be easy. I want the variable to be $width and for it to have px on the end. If i put a space, it doesnt work. If i put them together, it treats it as one big variable name. Could I ask someone the correct snytax to achieve this? Thanks Answer If you
Calculate total seconds in PHP DateInterval
What is the best way to calculate the total number of seconds between two dates? So far, I’ve tried something along the lines of: However, the days property of the DateInterval object seems to be broken in the current PHP5.3 build (at least on Windows, it always returns the same 6015 value). I also atte…
What sort algorithm does PHP use?
Internally speaking, which algorithm(s) does PHP use to implement the various sort functions it offers? It seems like the usort variants might use a different algorithm than the built in sorts, but I wanted to know. Where would I even find this information? Thanks! Answer You could find the information by loo…