I would like to do {unset($array[‘index’])} into a Smarty 3 template. Is such a syntax (or similar) supported ? After Googling and doc reading I can’t find something satisfying. Maybe I should ask for a feature request to Smarty dev team ? 🙂 Anyway, how would you do this given the currently …
Tag: php
Processing multi-dimensional $_FILES array
I have the following $_FILES array past through for processing from a support form My main problem is understanding the logic required in order to process the array, check each file is valid (which I already have a list of valid extensions) then rename and store the file appropriately. The solutions on Google…
Cyrillic transliteration in PHP
How to transliterate cyrillic characters into latin letters? This Transliteration PHP Extension would do this very well, but I can’t install it on my server. It would be best to have the same implementation but in PHP. Answer Try following code
Can’t print_r domDocument
I only see: DOMNodeList Object ( ) is this a php bug or something? How am I supposed to see the HTML elements from the object? Answer When you create a DOMDocument instance, you have a PHP object. The DOM classes do not implement a helpful __toString functionality. To get HTML from a DOMDocument instance, you…
What does the mysqli_error() expects parameter 1 to be mysqli, null given mean?
I have this PHP page: This is returning the error Warning: mysqli_error() expects parameter 1 to be mysqli, null given. Any idea why? Answer You need to define: $dbc before ex:
Next key in array
I have an array: How can I get the name of the next key? For example if the current array is gsda, I need bsdf. Answer Update: Note that this is not a valid answer, as it’s searching for values instead of keys. If the pointer of current() is on the right key, @Thomas_Cantonnet is right and you want to
PHPUnit: expects method meaning
When I create a new mock I need to call the expects method. What exactly it does? What about its arguments? I can’t find the reason anywhere (I’ve tried docs). I’ve read the sources but I can’t understand it. Answer expects() – Sets how many times you expect a method to be called…
What is better practice when storing a users full name in the database? 1 or 2 columns?
Is it considered better practice to store a first_name and a last_name in 2 separate columns? or would storing both in 1 column be ok? Answer Only you know that, really. It depends if you’re ever going to need to get those parts of the name back out separately. Storing first name and last name in a sing…
New line to paragraph function
I have this interesting function that I’m using to create new lines into paragraphs. I’m using it instead of the nl2br() function, as it outputs better formatted text. } The problem is that whenever I try to create a single line break, it inadvertently removes the first character of the paragraph …
Php Sanitize and Validate form with some character exceptions
I’m using in Php Sanitize and Validate Filters but I have problems to add some rules, I have some basic knowledge of php so I think this question is easy for you. I need to add a minimum and maximum number of characters (14-15) and I want to accept this characters ( – or space ) .The exact sequenc…