How To Merge Object Variables in PHP

Author: , June 11th, 2020

$merged_object = (object) array_merge((array) $object1, (array) $object2);

How To Read Multiple Lines of User Input from the Command Line in Perl

Author: , October 9th, 2019

Use Case: Export Apple Reminders from MacOS application to cleaned plain text, i.e. remove unwanted spaces, blank lines and square brackets PROCEDURE Click on a single item in the MacOS Reminders app list Select All (either Command-a or use Edit->Select All) Copy (either Command-c or use Edit->Copy) Open Terminal Run cleanme Paste the copied reminders […]

How To Trim Whitespace From Exploded Elements In PHP

Author: , May 7th, 2012

Here is a one-liner that explodes a string and trims whitespace from each element: $array = array_map(‘trim’,explode(‘,’,$str));

How To Loop Through Objects In JavaScript

Author: , May 15th, 2011

Coming from the Perl world, I wanted to emulate the following code in JavaScript:

What I found is that JavaScript uses “Objects” to contain hash-style data:

Also, one may use variables as key names by using the square-bracket notation, which evaluates variables first:

How to Sort Arrays in PHP

Author: , September 29th, 2009

There are 4 “key” functions for dealing with PHP array sorting. These four have the significant feature of keeping the associated key/value relationships intact. asort() – sort by value ascending arsort()– sort by value descending ksort()– sort by key ascending krsort() – sort by key descending For more information check out this php man page […]

How to reindex a simple array in PHP

Author: , September 28th, 2009

$array = array_values($array);