Skip to content
Advertisement

Tag: arrays

Looking for the same chars in two strings in PHP

Given two strings, what is the best approach in PHP to retrieve the characters which are in common, and those which are not? For instance, given the two strings: I would like to get something like: I saw there are word similarity functions which return a numeric value. However, I would like to retrieve each single char. My approach would

PHP: Why does this return “undefined offset” every time?

So basically this is an algorithm I made for a battleships game. I’m having problems with the while loop, I want to have the code inside the do while loop keep repeating, if the generated values already exist in a multidimensional array, and it looks like it actually works, because it generates correct values, but I keep getting the error

Counting entries in sub/subarray

I am working on a chat. I have an array that contains the info regarding the room (in the example below, 2 rooms (the lounge, the beach)). I have an issue when I have an empty room (in the example the beach), as it contains by default no user, (which is a Null user). I am trying to count, in

Transform text coma in an array

I am working with the PayPal API and I am trying to add multiple items to my itemList. My problem is that to make the itemList work, the array needs multiples variables: I am using a loop before, to set-up the items, which I am trying to gather into one variable: It doesn’t work and I think that the problem

Count number of columns in array php?

I have a simple function to count numbers of columns with specific value in the array: it works well while accept exists in the array. If not I get Undefined index: Accept. My array looks like that: How can I add something like isset here? Answer With oneliner is it not possible (or the code will be messy), so you

Advertisement