Converting to HTML, from form POST, etc

See here

Converting String To Variable

You don’t need to, but if you want to force to a particular type you can:

  $DeviceId = intval($DeviceId);

Converting Variables To String

No need, PHP automatically converts a varaible to the type needed for the context being used

  $number = 12345 & 67890;   //$number is used as a numeric varaible
  echo substr ($number, 3, 1);   //$number is used as a string

Convert copy and pasted text

  //Convert copy and pasted email addresses (seperate email addreses by comma or newline or both)
  $emails = preg_split("/[\r\n,]+/", $email_addresses, -1, PREG_SPLIT_NO_EMPTY);

Remove special characters from a string

  //Remove all special characters
  $MyString = str_replace(' ', '-', MyString);                  //Replaces all spaces with hyphens.
  $MyString = preg_replace('/[^A-Za-z0-9\-]/', '', $MyString);  //Remove all special characters
  
  //This string: 'a|"[email protected]£de^&$f g'
  //Will become: 'abcdef-g'
UK Electronic Designer
USEFUL?
We benefit hugely from resources on the web so we decided we should try and give back some of our knowledge and resources to the community by opening up many of our company’s internal notes and libraries through mini sites like this. We hope you find the site helpful.
Please feel free to comment if you can add help to this page or point out issues and solutions you have found, but please note that we do not provide support on this site. If you need help with a problem please use one of the many online forums.

Comments

Your email address will not be published.