Archive for December, 2009

PHP Multidimensional Arrays Tip

Sunday, December 27th, 2009

I hope this will help someone someday for it took me a minute to figure out.  I am working on a web application that requires the addition of datasets that can be unique or similar.  Each set is to be displayed on a unique row and each row will display data that is being pulled from a DB, a grid framework per se.  Users of the system will be able to alter the contents of the rows and rearrange the order of the rows on the fly before they can save them back to the DB.

I stored everything in multidimensional arrays and when adding new sets or new rows with keys that already exist in the sequence hindered the correct reordering of them.  Example:

The grid is comprised of

$set1[$key1][1]= $array1;

$set2[$key2][1] = $array2;

with $key1 and $key2 being numerical.

Adding a new row of $set1[$key1] at the end of the grid, i.e.,

$set1[$Key1][2] needed to generate the following order:

$set1[$key1][1]= $array1;

$set2[$key2][1] = $array2;

$set1[$Key1][2] = $array1;

However, no matter what I did to populate the arrays sequentially, the order reverted to:

$set1[$key1][1]= $array1;

$set1[$Key1][2] = $array1;

$set2[$key2][1] = $array2;

The easiest fix I could find (I know several others are out there) to achieve the goal was change the keys from numerical to strings.  I did that by combining them and separating them by a glue character (-, @, _, etc.).  The result was:

$set1[$key1_1]= $array1;

$set2[$key2_1] = $array2;

$set1[$Key1_2] = $array1;

To process the data afterward, I split the keys into an array by taking into the account the glue character that I used.

She Is

Saturday, December 26th, 2009

A lot of times I get asked about our story. How it started, where we met, etc. Usually my face gets red and the words refuse to come out of my mouth. I am going to try to put a short pictures storyline together and refer all future questions about the subject to here. This is how it goes:

I met her 9 years ago at SIU; thanks Ayum, I owe you big time. Due to reasons that are not important, we couldn’t be together. However, we remained friends and kept in touch after she left. We even visited each other!

This was in Pensacola, FL where she moved after she graduated. I think that was when I realized that she is going to be my wife one day, even though we were just friends.
I got to meet her parents and really enjoyed my time with them.

g2
g3 She came and visited me in Carbondale. That was the first time I cooked for her. I think I might have ignited something in her or struck a chord when she tasted the food that I made.

Afterwards, we kept in touch but we got disconnected for a while. She moved to Chicago to go to Graduate School and we lost contact. I called her Mom and she gave me her contact information. Thank you Mrs. Lawrence (I owe you big time too).

I attended her graduation from Graduate School and that was when we started to be an item. Chicago
g7 We both looked beyond the obstacles and decided to give it a try.
We took it to the next level. g8
g6 And we eventually landed here.

A lot has been left out since the journey took almost a decade so far. For me, what is important is that it is just the beginning of a very long journey with the love of my life, my peace of mind and my trophy of trophies. She is all the aforementioned; a million other words put together will not do justice to what she means to me.

E & H

I love you Mrs. Gasim