Showing posts with label php. Show all posts
Showing posts with label php. Show all posts

Friday, July 1, 2011

PHP concat variable name with str/string

In PHP, concatenate variable names with strings by using curly brackets {}.

The Shorter version
<?php
       // setting every $nvar* to ":)"
       $nameArray = array("Alice", "Bob", "Charlie");
       foreach ($nameArray as $name) {
           ${ "nvar" . $name } = ":)"; 
       }
?>

and

The Longer version
<?php
       // setting every $nvar* to ":)"
       $nameArray = array("Alice", "Bob", "Charlie");
       foreach ($nameArray as $name) {
           $nameVar = "nvar" . $name;
           ${ $nameVar } = ":)"; 
       }   
?>

are the same as

The Brute-force version
<?php
       // setting every $nvar* to ":)"
       $nvarAlice = ":)";
       $nvarBob = ":)";
       $nvarCharlie = ":)";
?>

Read documentations here.

Saturday, March 26, 2011

making youtubelooper.com notes

http://youtubelooper.com/

htmlentities() - to prevent xss
urlencode() - to keep the lyric's spaces and new lines
<label> - to click on


<textarea onclick="this.focus(); this.select();"></textarea> - make it select all when clicked

style changes

Fixed something on bottom right of page with CSS:

     position: fixed;
     bottom: 0;  
     right: 0;

css to make pointer into a hand
    cursor: pointer;


get jquery: <script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
jQuery to focus on something at the beginning:

  $(document).ready(function(){
      $("#inputboxid").focus();
  });



name.com sigh doesn't allow very long URL's