It is Bip Bip Bipool

October 22, 2007

PHP : usort function

Filed under: Uncategorized — bipool @ 16:57

Before somedays , I was working on sorting issue. I was using usort function. In this function, you can define sort criteria. Here you can send 2 variable as parameter , then write ascending or descending or any criteria .

I was using this and I had multi-dimensional array . Thats why, I was writing in the body part of the usort like following
$a[0] > $b[0]

And this way, It is working fine.

But When I using a variable instead of hard code ’0′ like following

$index = 0;

$a[$index] > $b[$index]

It is not working. It is not accepting variable here.

Then I was trying to use ‘create_function()’ where i was using variable and thats work really fine

Thanks

Advertisement

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Theme: Banana Smoothie. Blog at WordPress.com

Follow

Get every new post delivered to your Inbox.