Jump to content

[SOLVED] Two array questions


Agum

Recommended Posts

I have two questions regarding array. I would like to do the following in an efficient way.

 

1) I have two arrays. They contain ID numbers (unique). The first array has, say 100 elements. The second array has, say 20 elements. Every ID that appears in second array is also in the first array (guaranteed). What is the best way to search in the first array and remove every element that appears in the second array?

 

2) I have a multidimensional array/hash like this:

arr[0]['id'] = 123;

arr[0]['name'] = "John Doe";

arr[1]['id'] = 456;

arr[1]['name'] = "Peter Smith";

...

I would like to "sort" this array based on the "name" part of the array. The id number needs to be kept with that particular name it comes with. What's the best way to do this?

 

Thanks.

 

Link to comment
https://forums.phpfreaks.com/topic/58618-solved-two-array-questions/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.