Skip to content

Tag: php

Smarty: unset an array index in template

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 …

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…

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…

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 …