Skip to content

Tag: arrays

php array sorting with accents

I am using this to sort according to last name: But – when in last name is accent, e.g. Šiko, Áron, etc, these names are at the end. How can I sort it properly? Answer Use multi-byte string functions. There is a function called strcoll which seems to suit your needs. More info: On how to sort an array o…

Convert list into an array using php. How?

I have a function called listelements(), which outputs text like <li>text1</li><li>text2</li>. I have more than 500 elements. Now I want to convert it into an array. Can anyone help me? Thanks. Note: I’m using php Update: The thing i want to achieve is alphabetical navigation. As…

How to search in an array with preg_match?

How do I search in an array with preg_match? Example: Answer In this post I’ll provide you with three different methods of doing what you ask for. I actually recommend using the last snippet, since it’s easiest to comprehend as well as being quite neat in code. How do I see what elements in an arr…

Array of PHP Objects

So I have been searching for a while and cannot find the answer to a simple question. Is it possible to have an array of objects in PHP? Such as: For some reason I have not been able to find the answer anywhere. I assume it is possible but I just need to make sure. Answer The best place to