Sunday, July 8, 2012

Overriding properties in CSS

While working on the design of my site using Twitter's bootstrap, I had a hard time resizing the height of the search box, which due to a strange reason was looking much smaller than it should.
The first thing I tried was making my own CSS file and make a class style.css . However even after adding that class to my search box div, there was no change. This is because the class contained within the bootstrap.css is more specific. To enforce a change however all that needs to be done is add !important following the property in css. As an example :-
.search
{ height: 28px !important; }

Tuesday, July 3, 2012

multi-dimensional array in php

Similar to Java, php also allows us to have multi-dimensional arrays. As an example of this
$food = arrays('healthy' => arrays('salad', 'chicken') , 'unhealthy' => arrays('ice cream', 'pizza'));


Now to access salad element, the following needs to be done.

$food[healthy][0];

associative arrays in php

Associative arrays are similar to arrays discussed previously, however they have a key attached to a value.

As an example

$food = ('pizza' => 300 , 'pasta' => 100, 'ice cream' =>100 );


to get the value stored at key 'pizza' :-


$food['pizza'];

arrays in php

An array can be simply defined as a collection of data stored within one variable. To do this in php initialize the variable using the dollar sign, and then in the right hand side add the values within rounded brakets each data entry separated with a inverted comma. Bear in mind that the types of the data should not be different for each value within that array.

An example of an array :-
$food = ('apple', 'chicken' ,' sandwich');