|
|
|
codepad
|
|
|
|
Saved pastes by balajimca:
<?php
$array = array(0 => 100, "color" => "red");
print_r(array_keys($array));
$array = array("blue", "red", "green", "blue", "blue");
|
| view (11 lines, 16 lines of output) |
<?php
$string = 'April 15, 2003';
$pattern = '/(\w+) (\d+), (\d+)/i';
$replacement = '${1} 2,$3';
echo preg_replace($pattern, $replacement, $string);
|
| view (6 lines, 1 line of output) |
<?php
$rate=12.00;
$percent = 5;
$newrate = ($rate - (($rate/100)*$percent));
print $newrate;
|
| view (6 lines, 1 line of output) |
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
|
| view (51 lines, 2 lines of output) |
<?php
if(isset($_POST[sub])) {
function find_user($filename, $email) {
$f = fopen($filename, "r");
|
| view (27 lines, 5 lines of output) |
<?php
$beginning = 'foo';
$end = array('bar');
$result = array_merge((array)$beginning, (array)$end);
print_r($result);
|
| view (6 lines, 5 lines of output) |
<?php
$array = array(0 => 100, "color" => "red");
print_r(array_keys($array));
$array = array("blue", "red", "green", "blue", "blue");
|
| view (11 lines, 16 lines of output) |
<?php
$string = '60, 1, 1, 188, pdgje5565';
$output_array = array_map('trim',explode(',',$string));
|
| view (6 lines, 8 lines of output) |
<?php
$sites = array("Nettuts+"=>"ets", "Psdtuts+"=>"erre", "Mobiletuts+"=>"swa", "Mactuts+"=>"oooo");
$k = array_rand($sites);
echo $k."\n";
$sites[$k];
|
| view (7 lines, 2 lines of output) |
<?php
$sites = array("Nettuts+", "Psdtuts+", "Mobiletuts+", "Mactuts+");
$k = array_rand($sites);
$sites[$k];
echo $sites[$k];
|
| view (6 lines, 1 line of output) |
<?php
// Delimiters may be slash, dot, or hyphen
$date = "04.30.1973";
list($month, $day, $year) = split('[/.-]', $date);
echo "Month: $month; Day: $day; Year: $year<br />\n";
|
| view (8 lines, 9 lines of output) |
<?php
//facebook like past time display
function facebook_style_date_time($timestamp){
$difference = time() - $timestamp;
$periods = array("sec", "min", "hour", "day", "week", "month", "years", "decade");
|
| view (24 lines, 1 line of output) |
<?php
function facebook_style_date_time($timestamp){
$difference = time() - $timestamp;
$periods = array("sec", "min", "hour", "day", "week", "month", "years", "decade");
$lengths = array("60","60","24","7","4.35","12","10");
|
| view (23 lines, 1 line of output) |
<?php
$timezone="Asia/Calcutta";
date_default_timezone_set($timezone);
echo date('y-D-M h:i:s');
|
| view (6 lines, 1 line of output) |
<?php
date_default_timezone_set('Asia/Delhi');
$timestamp = strtotime("+1 month +2 days +0 hours +0 minutes 2 seconds")."\n";
echo $timestamp;
|
| view (7 lines, 2 lines of output) |
<?php
$timestamp = strtotime("+1 month +2 days +4 hours +32 minutes 2 seconds")."\n";
echo $timestamp;
echo date('y-D-M h:i:s', $timestamp);
?>
|
| view (5 lines, 2 lines of output) |
<?php
$my_array = array("Dog","Cat",45,'f');
var_dump($my_array);
echo "\n";
var_export($my_array);
|
| view (11 lines, 24 lines of output) |
<?php
function some_func($a, $b) {
for ($i = 0; $i < func_num_args(); ++$i) {
$param = func_get_arg($i);
echo "Received parameter $param.\n";
|
| view (17 lines, 9 lines of output) |
<?php
$var = array("naMe"=>"madhu","desTination"=>"developer");
print_r(array_change_key_case($var,CASE_UPPER));
print_r(array_change_key_case($var,CASE_LOWER));
?>
|
| view (5 lines, 10 lines of output) |
<?php
$test = array ('first'=>'balaji','second'=>'balaji2','third'=>'balaji3');
print_r(array_chunk($test,2));
?>
|
| view (4 lines, 14 lines of output) |
<?php
$array = array("2011-September_38","2011-September_10","2010-November_1","2011-June_50","2011-June_4","2009-November_9","2009-November_29","2010-December_19","2011-September_1");
function monthCompare($a, $b) {
$count = substr($a,strpos($a,'_'));
$count =strlen($count);
|
| view (36 lines, 6 lines of output) |
<?php
$array = array("2011-September_38","2011-September_10","2011-June_50","2011-June_4","2009-November_9","2009-November_29","2010-December_19","2011-September_1");
function monthCompare($a, $b) {
$count = substr($a,strpos($a,'_'));
$count =strlen($count);
|
| view (36 lines, 6 lines of output) |
<?php
$array = array("2011-September_38","2011-June_4","2009-May_3","2009-May_45","2010-March_2","2010-November_9","2011-December_29","2010-March_19");
function yearmonthCompare($a, $b) {
$count = substr($a,strpos($a,'_'));
$count =strlen($count);
|
| view (19 lines, 51 lines of output) |
<?php
$array = array("2011-September_38","2011-June_4","2009-May_45","2010-November_9","2011-December_29","2010-March_19");
function monthCompare($a, $b) {
$count = substr($a,strpos($a,'_'));
$count =strlen($count);
|
| view (14 lines, 9 lines of output) |
<?php
$array = array("2011-September_38","2011-June_4","2010-November_9","2011-November_29","2010-December_19");
function monthCompare($a, $b) {
$count = substr($a,strpos($a,'_'));
$count =strlen($count);
|
| view (14 lines, 8 lines of output) |
<?php
$array = array("2011-September_38","2011-June_4","2011-November_9");
function monthCompare($a, $b) {
$a = strtolower(substr($a,5,-3));
$b = strtolower(substr($b,5,-3));
|
| view (29 lines, 10 lines of output) |
<?php
$date=array('2009-03','2010-01','2009-02');
for ($i=0;isset($date[$i]);$i++) {
$datess=explode('-',$date[$i]);
|
| view (12 lines, 6 lines of output) |
<?php
$date=array('2009-03','2010-01','2009-02');
for ($i=0;isset($date[$i]);$i++) {
$datess=explode('-',$date[$i]);
|
| view (12 lines, 6 lines of output) |
<?php
$date=array('2009-03','2010-01','2009-02');
for ($i=0;isset($date[$i]);$i++) {
$datess=explode('-',$date[$i]);
|
| view (10 lines, 6 lines of output) |
<?php
//set date array to list of dates in y-d-m format
$date=array('2009-03','2010-01','2009-02');
for ($i=0;isset($date[$i]);$i++) {
$datess=explode('-',$date[$i]);
|
| view (18 lines, 6 lines of output) |
<?php
function sortMonths($a1, $b1) {
$a = date("Y F",$a1);
$b = date("Y F",$b1);
if ($a->received_date == $b->received_date)
|
| view (17 lines, 1 line of output) |
<?php
//convert timestamp to normal date
$test=array(1316427274,1289909504);
foreach($test as $sort)
{
|
| view (14 lines, 5 lines of output) |