Skip to content

Tag: function

php header location vs php_redirect

What’s the difference between the function “HTTP_redirect” and “header location” in PHP ? When must I use the function “HTTP_redirect” ? When must I use the function “header location” ? Look that: https://php.net/manual/en/function.http-redirect.php &#8211…

PHP number abbreviator

Edit: Function below now does the abbreviation correctly, implemented @Asad ‘s solution Hi I am currently working on a like button, I’ve got all the base functionality working nicely however I have started the number abbreviation code and hit a wall as I can’t figure out how to make the abbr…

PHP Function to return string

I am fairly new to PHP. I have a function which checks the cost of price. I want to return the variable from this function to be used globally: Answer You should simply store the return value in a variable: The $deliveryPrice variable above is a different variable than the $deliveryPrice inside the function. …

explode an array of delimited strings into two arrays

I have the following array: that I need to split into two arrays using “-” as delimiter: and Is there anything like array_explode that does what I want? or a combination of php array functions? I’d like to do this without going through my own for/each loop, if possible, or at least minimize …

Function to count MySQL rows using WHERE

am making function to count rows using “WHERE”, but i get a mysql error Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:AppServwwwtesttestindex.php on line 9 Unknown column ‘1’ in ‘where clause’ here is my function i’ve created t…

PHP function missing argument error

My validate function looks like that Function call example As you see, my validate function has 3 input vars. I’m not using second var – $data2 often, that’s why set it to 0 by default. But when I’m calling this function as given example (as far as I know it means $data=$lname, $data2=…