• PHP
  • Ruby on Rails
  • MySQL
  • Linux
    • SELINUX
    • Fedora
    • debian
  • Apache
  • nginx
  • AJAX
Albertech.net

Category Archives: Php

PHP – Removing alpha characters from an entire array using closure

May 7, 2013 12:40 pm / Albertech.net

Here’s a quick way to remove all alpha characters from an array using PHP closures (PHP 5.3+)

array_walk($myarray, function(&$element){ $element = trim($element,"ABCDEFGHIJKLMNOPQRSTUVWXYZ"); });

You can also remove all numbers from an array similarly

array_walk($myarray, function(&$element){ $element = trim($element,"0123456789"); });

The variable must be passed by reference in order to change the values of the original array. I really like the addition of closures, which reduces the need to create a new method for simple operations.

Share this:

  • Facebook
  • Google
  • Twitter
  • Print
  • Email
Posted in: PHP / Tagged: closure, PHP

Zend Form – Adding a checkbox element with label to the side

February 21, 2013 7:42 pm / Albertech.net

Here’s the fastest way to add a checkbox element with a label to the side of it (inline) using the Zend Framework. By default, the checkbox is put on a separate line after the label,which isn’t a standard practice. This can be done using some CSS and a Zend Decorator element.

CSS Code:

label.inline {
display: inline;

}
.inlinecheck{
clear: both;
float: left;
width: 25px;
margin-bottom: 0;
}

Zend PHP Code:

$this->addElement('checkbox', 'mycheckbox', array(
'label' => 'My Label',
'name' => 'mycheckbox',
));
$this->getElement('mycheckbox')->addDecorator('Label', array('placement' => 'APPEND'));
$this->getElement('mycheckbox')->addDecorator('HtmlTag', array('tag' => 'dl','class' => 'inlinecheck'));

Rename mycheckbox with the name of your element and set the label accordingly.

Share this:

  • Facebook
  • Google
  • Twitter
  • Print
  • Email
Posted in: Frameworks, PHP / Tagged: checkbox, zend

PhpStorm sale 50% off

September 12, 2012 9:32 am / Albertech.net

 

JetBrains has their annual sale where they offer PhpStorm for $49. This is a good time to pick up a really good IDE for PHP. I’ve used many different IDE editors for PHP including NuSphere PHPEd, Eclipse, and NetBeans. The standout features for PhpStorm are the speed, cross-platform compatibility (OSX, Windows, etc), and intelligent code completion for classes and methods. It really helps speed up development time when you have a large codebase. Another nice feature with PhpStorm is the built-in Git integration. At 50% the regular price of $99 — its a great deal for $49.

Update 9/20/2012 – Sale ended. They now offer a new $29 academic license option for students.

http://www.jetbrains.com/phpstorm/buy/index.jsp?BacktoSchool

Share this:

  • Facebook
  • Google
  • Twitter
  • Print
  • Email
Posted in: IDE, PHP

Zend Framework – Setting global variables in application.ini

August 17, 2012 5:13 pm / Albertech.net

Here are some basic instructions to setting up global variables in Zend Framework using the application.ini file (application/configs/application.ini):

1) Create a service name for your global variable in application.ini. Usually, you group them by the API name. 

For instance, if you have an API called “myapi” and you want to store a global variable myvar = “1234”.  Add the following line to your application.ini

myapi.myvar = 1234

2) In your controller, use the following code to access the global variable:
$myapi = $this->getInvokeArg('bootstrap')->getOption('myapi');
$myvar = $myapi["myvar"];


Share this:

  • Facebook
  • Google
  • Twitter
  • Print
  • Email
Posted in: PHP, Zend Framework / Tagged: config, global variables, zend framework

phpDocumentor – GraphViz package install on Mac OSX

June 26, 2012 10:13 am / Albertech.net

phpDocumentor has a few dependencies in order to work correctly on OSX. If you get the following error message when generating documentation in phpdoc:

Unable to find the `dot` command of the GraphViz package

you will need to install the GraphViz package via homebrew.

If you don’t have homebrew installed on OSX, here is a link to it: http://mxcl.github.com/homebrew/

brew install graphviz

This will quickly install GraphViz on OSX. PhpDocumentor will be able to generate the Class Inheritance Diagrams after GraphViz is installed.

Share this:

  • Facebook
  • Google
  • Twitter
  • Print
  • Email
Posted in: Mac OS X, PHP / Tagged: graphviz install

Post Navigation

← Older Posts
 

Categories

  • AJAX
  • Android
  • Apache
  • Canon Cameras
  • Cloud
  • CMS
  • Computer Mods
  • Conferences
  • Deals
  • debian
  • Fedora
  • Flash
  • Frameworks
  • git
  • Hardware
  • HTML
  • IDE
  • iPhone
  • iPhone App Review
  • jQuery
  • Linux
  • Mac OS X
  • MySQL
  • nginx
  • PHP
  • portfolio
  • Puppet
  • Ruby on Rails
  • Script Reviews
  • SELINUX
  • Software
  • Software Review
  • SQL Server
  • statistics
  • Tech
  • Tomcat
  • Uncategorized
  • VMWARE
  • VPS
  • Windows
  • wordpress
  • Zend Framework

Blogroll

  • DragonAl Flickr
  • Dropbox – Free 2GB Account
  • James' Blog
  • Javascript Compressor
  • PHP Builder Community
  • PHP-Princess.net
  • Rubular – Regular Expression Validator
  • The Scale-Out Blog
  • Tiny MCE

Tags

activation AJAX android antec Apache AWS awstats canon coda codeigniter debian enclosure external free G1 install vmware tools Internet Explorer iphone 5 jquery Linux mx-1 MySQL office 2007 OSX photoshop PHP plugin plugins portfolio redesigned website review rewrite script security SELinux ssh tinymce tutorial upgrade VMWARE vmware server wordpress wordpress mu XSS zend framework
© Copyright 2013 Albertech.net
Infinity Theme by DesignCoral / WordPress
loading Cancel
Post was not sent - check your email addresses!
Email check failed, please try again
Sorry, your blog cannot share posts by email.