Skip to content
Advertisement

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 of

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 of now my function displays links in list order. Instead of that i want

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 array that matches my regular

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

array_uintersect() gives unexpected results when callback only returns 0 or 1

I have a custom callback in my array_uintersect() call because I need to case-sensitively compare strings in two elements while comparing rows between two multi-dimensional arrays. OUTPUT I can’t understand why this code doesn’t produce the correct output which should be an array with “B”, “C” and “D” elements, because only “A” element is different from $vieja to $nueva… if

Advertisement