Using variables with bgStretcher

I am just starting with php programming and I have this question:

Is there any way to set the width and height values of bgStretcher image with variables?

<?php $arrPath=array("bg" => "http://mydomain.com/myimage.jpg"); $w=1500; $h=800; ?>

$(document).ready(function(){
     $(document).bgStretcher({
           images: $arrPath["bg"], imageWidth: $w, imageHeight: $h
     });
});

I'm getting the variable name instead of its values...

Answers


Try this:

$(document).ready(function(){
     $(document).bgStretcher({
           images: <?php echo $arrPath["bg"]; ?>, imageWidth: <?php echo $w; ?>, imageHeight: <?php echo $h; ?>
     });
});

Additionally to Indranil's answer, another way to write this to save some space is the following:

<?php $arrPath=array("bg" => "http://mydomain.com/myimage.jpg"); $w=1500; $h=800; ?>

$(document).ready(function(){
     $(document).bgStretcher({
           images: <?=$arrPath["bg"]?>, imageWidth: <?=$w?>, imageHeight: <?=$h?>
     });
});

Need Your Help

IP addresses of agents registered with the Main Container in JADE?

ip-address agents agents-jade

I have a website at the back end of which I have a JADE main container running. Multiple machines can register with this main container. So, I want to know if the JADE API supports getting the IP

Layout alignment in List Activity

android layout

I'm creating a list view in Android where each row is shown with LinearLayout. The problem that I have is that since the text is different in each line, it isn't aligned in the same way. See for e....