FAQ

Search Discussions

666 discussions - 925 posts

  • Some surprisingly wrong results (php 5.2.0): date and time seem not coherent: <?php // Date: Default timezone Europe/Berlin (which is CET) // date.timezone no value $basedate = strtotime("31 Dec 2007 ...
    BeatBeat
    Oct 1, 2007 at 8:35 pm
    Dec 14, 2014 at 12:00 pm
  • Simple function that converts more than one <br ,<br/ ,<br / ... to a <p </p . Maybe it's useful for someone =) function br2p($string) { return preg_replace('#<p [\n\r\s]*?</p #m', '', '<p ...
    Nacho ExrNacho Exr
    Oct 31, 2007 at 4:53 pm
    Jun 13, 2013 at 11:04 am
  • <?php function array_unique_FULL($array){ foreach($array as $k = $v){ if(is_array($v)){ $ret=F::array_unique_FULL(array_merge($ret,$v)); }else{ $ret[$k]=$v; } }//for return array_unique($ret); } ? ...
    Array_unique_fullArray_unique_full
    Oct 11, 2007 at 7:55 am
    Jan 23, 2011 at 5:12 pm
  • Sometimes it is helpful to check for the existance of a file which might be found by using the include_path like in include("file_from_include_path.php"); A simple function iterates the include_path ...
    AlexAlex
    Oct 3, 2007 at 3:24 pm
    Jun 1, 2009 at 12:54 pm
  • Updating internal's PHP timezone database (5.1.x and 5.2.x) http://fischer.tecnologia.ws/en/node/1 ---- Server IP: 69.147.83.197 Probable Submitter: 200.234.208.27 ---- Manual Page -- ...
    HerbertdotfischerattgeemaildotcomHerbertdotfischerattgeemaildotcom
    Oct 11, 2007 at 8:42 pm
    May 20, 2009 at 2:40 am
  • This function could be useful to somebody if you want to insert an XML into another when building an XML from many different files. Note that you must specify a name for the node in which the child ...
    DavidDavid
    Oct 31, 2007 at 3:29 am
    May 18, 2009 at 1:12 am
  • This is the fonction for PHP4 : function array_combine($arr1,$arr2) { $out = array(); foreach($arr1 as $key1 = $value1) { $out[$value1] = $arr2[$key1]; } return $out } ---- Server IP: 194.246.101.61 ...
    KhalyKhaly
    Oct 4, 2007 at 9:10 am
    Feb 23, 2008 at 1:51 am
  • Check for duplicates in an array (as opposed to removing them): if (array_unique($array) != $array) { echo "Duplicate located in array."; } ---- Server IP: 69.147.83.197 Probable Submitter: ...
    Cz12Cz12
    Oct 18, 2007 at 9:18 pm
    Dec 16, 2007 at 12:09 pm
  • Regarding cyberchrist at futura dot net's function. It makes an unnecessary array_merge(); the elements of $b that are merged with those of $a are immediately removed again by the array_diff(). The ...
    HayleywatsonHayleywatson
    Oct 17, 2007 at 11:08 am
    May 6, 2014 at 10:09 pm
  • I've been working on a project for a while now, and for example in my DB handler I wanted to load var's to the objects late; However, without doing it manually on the object itself but through a ...
    RandallgirardRandallgirard
    Oct 26, 2007 at 5:14 pm
    Mar 18, 2014 at 2:09 am
  • A simple funtion to format american dollars. <? function formatMoney($money) { if($money<1) { $money='&cent;'.$money*100; } else { $dollars=intval($money); $cents=$money-$dollars; $cents=$cents*100; ...
    Uliciadrian01Uliciadrian01
    Oct 6, 2007 at 9:34 am
    Feb 24, 2014 at 11:07 pm
  • If you intend to pass a copy of an object to a function, then you should use 'clone' to create a copy explicity. In PHP5, objects appear to always be passed by reference (unlike PHP4), but this is ...
    ChuckieChuckie
    Oct 28, 2007 at 4:31 pm
    Feb 23, 2014 at 5:15 pm
  • I was wondering what was quicker: - return a boolean as soon I know it's value ('direct') or - save the boolean in a variable and return it at the function's end. <?php $times = 50000; function ...
    Mr XanaduMr Xanadu
    Oct 12, 2007 at 8:54 am
    Jan 2, 2014 at 11:18 pm
  • Don't forget that using callbacks in a class requires that you reference the object name in the callback like so: <?php $newArray = array_filter($array, array($this,"callback_function")); ? Where ...
    NospamNospam
    Oct 23, 2007 at 6:48 pm
    Oct 22, 2013 at 8:00 am
  • <?php $tmp_array = "123,232,141"; if (strval(intval($tmp_array)) == $tmp_array) { echo "'".intval($tmp_array)."' equals '$tmp_array'\n"; } else { echo "'".intval($tmp_array)."' does not equal ...
    ShermyShermy
    Oct 17, 2007 at 12:32 pm
    Oct 22, 2013 at 8:00 am
  • the function posted is false, hier the correction: function rstrpos ($haystack, $needle, $offset) { $size = strlen ($haystack); $pos = strpos (strrev($haystack), strrev($needle), $size - $offset); if ...
    T HornbergerT Hornberger
    Oct 17, 2007 at 11:48 am
    Oct 22, 2013 at 8:00 am
  • It should be noted that version_compare() considers 1 < 1.0 < 1.0.0 etc. I'm guessing this is due to the left-to-right nature of the algorithm. ---- Server IP: 212.63.193.10 Probable Submitter: ...
    RickardanderssonRickardandersson
    Oct 30, 2007 at 9:15 pm
    Oct 22, 2013 at 6:47 am
  • You should probably try to avoid changing any of the items in the args array. Consider this example: ---------- function a(&$value) { echo "start a: $value\n"; b(); echo "end a: $value\n"; } function ...
    MisterpibMisterpib
    Oct 17, 2007 at 4:33 pm
    Oct 16, 2013 at 2:43 pm
  • filesize() acts differently between platforms and distributions. I tried manually compiling PHP on a 32bit platform. Filesize() would fail on files 2G. Then I compiled again, adding CFLAGS=`getconf ...
    MagicaltuxMagicaltux
    Oct 16, 2007 at 5:56 am
    Jan 22, 2013 at 12:19 am
  • $test = true and false; --- $test === true $test = (true and false); --- $test === false $test = true && false; --- $test === false ---- Server IP: 195.46.80.5 Probable Submitter: 158.195.96.161 ---- ...
    Peter KutakPeter Kutak
    Oct 1, 2007 at 7:34 pm
    Aug 2, 2012 at 3:12 pm
  • Other languages (in my case Java) allow access to multiple values for the same GET/POST parameter without the use of the brace ([]) notation. I wanted to use this function because it was faster than ...
    DonovanjimenezDonovanjimenez
    Oct 18, 2007 at 6:34 pm
    Aug 2, 2012 at 1:37 pm
  • Below is the function for making an English-style list from an array, seems to be simpler than some of the other examples I've seen. <?php function ImplodeProper($arr, $lastConnector = 'and') { if( ...
    14131413
    Oct 10, 2007 at 10:40 pm
    Aug 2, 2012 at 1:19 pm
  • This code implodes same as the PHP built in except it allows you to do multi dimension arrays ( similar to a function below but works dynamic :p. <?php function implode_md($glue, $array, ...
    SinatoskSinatosk
    Oct 7, 2007 at 12:40 pm
    Aug 2, 2012 at 1:19 pm
  • To go further with Fabian's comment: The XML specification (production 66) says that (decimal) numeric character references start with '&#', followed by one or more digits [0-9], and end with a ';' - ...
    HayleywatsonHayleywatson
    Oct 1, 2007 at 10:14 pm
    Jan 10, 2012 at 8:12 pm
  • Fabian's observation that chr(039) returns "a heart character" is explained by the fact that numeric literals that start with '0' are interpreted in base 8, which doesn't have a digit '9'. So 039==3 ...
    HayleywatsonHayleywatson
    Oct 1, 2007 at 9:53 pm
    Jan 10, 2012 at 8:12 pm
  • Bafflingly, html_entity_decode() only converts the 100 most common named entities, whereas the HTML 4.01 Recommendation lists over 250. This wrapper function converts all known named entities to ...
    MattrobinsonMattrobinson
    Oct 22, 2007 at 6:09 pm
    Jan 10, 2012 at 8:12 pm
  • Whilst implementing my RSS_FEED reader, I stumbled upon a slight issue, typically on RSS feeds such as the NY Times ones : quotes and apostrophes were replaced by question tags. For example : "the ...
    EewonEewon
    Oct 20, 2007 at 4:18 pm
    Oct 12, 2011 at 11:13 pm
  • If you have a class which defines a constant which may be overridden in child definitions, here are two methods how the parent can access that constant: class Weather { const danger = 'parent'; ...
    Nrg1981{at}hotmail{dot}comNrg1981{at}hotmail{dot}com
    Oct 5, 2007 at 1:18 pm
    Aug 3, 2011 at 1:26 pm
  • A further implementation of the great rstrpos function posted in this page. Missing some parameters controls, but the core seems correct. <?php // Parameters: // // haystack : target string // needle ...
    GiulionospamatiunknowndotorgGiulionospamatiunknowndotorg
    Oct 31, 2007 at 10:17 am
    Aug 3, 2011 at 1:13 pm
  • @egingell at sisna dot com - Use of __call makes "overloading" possible also, although somewhat clunky... i.e. <?php class overloadExample { function __call($fName, $fArgs) { if ($fName == 'sum') { ...
    Zachary CraigZachary Craig
    Oct 9, 2007 at 5:12 am
    Jun 20, 2011 at 3:28 pm
  • @ zachary dot craig at goebelmediagroup dot com I do something like that, too. My way might be even more clunky. <?php function sum() { $args = func_get_args(); if (!count($args)) { echo 'You have to ...
    EgingellEgingell
    Oct 12, 2007 at 6:26 pm
    Jun 20, 2011 at 3:28 pm
  • Re: Renumbering arrays: This (from rcarvalhoREMOVECAPS at clix dot pt): $a = array_merge($a, null); does not renumber the array in PHP5. However this: $a = array_merge($a, array()); does renumber the ...
    Sam_hunting2004Sam_hunting2004
    Oct 18, 2007 at 2:42 pm
    Jun 20, 2011 at 3:23 pm
  • Re: public at kreinacke dot com It has long been a point of frustration to me that md5() functions don't produce the same results as the *nix md5sum program. Reading your comments about the ...
    SantacruzskellySantacruzskelly
    Oct 17, 2007 at 3:16 am
    Jun 20, 2011 at 3:15 pm
  • Using the Unix 'file' program with the -i switch will not work reliably. Consider the following plain-text CSV file (we'll call it 'error.csv'), which has the contents: ...
    DanielwalkerDanielwalker
    Oct 30, 2007 at 4:29 pm
    Apr 26, 2011 at 9:31 am
  • There are a couple of things you can do for cleaner code if you want the keys returned from the array. I am not sure how they each impact performance, but the visual readability is more beneficial ...
    MickMick
    Oct 30, 2007 at 11:48 pm
    Mar 22, 2011 at 1:48 pm
  • How about something like this: function goodFloor($x) { return floor(round($x, strlen((string)($x)))); } It's not elegant but at least short... Regards, Wojciech ---- Server IP: 195.136.184.34 ...
    MoveatcharacterMoveatcharacter
    Oct 23, 2007 at 12:33 pm
    Mar 10, 2011 at 3:10 pm
  • Smaller version for PHP5 <?php # array array_unique_save (array array [, bool preserve_keys] ) function array_unique_save ($a, $pk = true) { $a = array_diff_key($a, array_unique($a)); return ($pk ? ...
    MewMew
    Oct 2, 2007 at 7:04 am
    Jan 23, 2011 at 5:12 pm
  • To svenxy AT nospam gmx net AND rob at digital-crocus dot com <?php $zones = array('192.168.11', '192.169.12', '192.168.13', '192.167.14', '192.168.15', '122.168.16', '192.168.17' ); natsort($zones); ...
    Jc GlombardJc Glombard
    Oct 9, 2007 at 1:18 pm
    Jan 23, 2011 at 4:16 pm
  • After much messing around to get php to store session in a database and reading all these notes, I come up with this revised code based on 'stalker at ruun dot de' class. I wanted to use PEAR::MDB2. ...
    ShaunShaun
    Oct 8, 2007 at 4:36 pm
    Jan 23, 2011 at 4:07 pm
  • In the below example posted by "shaun at shaunfreeman dot co dot uk". You shouldn't call gc() within the close() method. This would undermine PHP's ability to call gc() based on ...
    RsumibcayRsumibcay
    Oct 26, 2007 at 5:43 pm
    Jan 23, 2011 at 4:06 pm
  • The following works for connecting via POP3 to a gmail server: imap_open("{pop.gmail.com:995/pop3/ssl/novalidate-cert}INBOX", $username, $pasword); ---- Server IP: 209.41.74.194 Probable Submitter: ...
    Rhaft22Rhaft22
    Oct 4, 2007 at 1:27 am
    Jan 22, 2011 at 2:20 am
  • Here the workaround to the bug of strtotime() found in my previous comment on finding the exact date and time of "3 months ago of last second of this year", using mktime() properties on dates instead ...
    BeatBeat
    Oct 1, 2007 at 10:39 pm
    Jan 9, 2011 at 4:55 pm
  • Here are my functions to do a 128 bit aes encryption which is transmitted to the dachser parcel tracking system via url. They expect a true aes 128 bit encryption an process the reqest by a java ...
    At) (dotAt) (dot
    Oct 26, 2007 at 1:22 pm
    Dec 13, 2010 at 4:13 pm
  • QUOTE from arnold at helderhosting dot nl: It is not possible to use the function 'pcntl_fork' when PHP is used as Apache module. You can only use pcntl_fork in CGI mode or from command-line. Using ...
    MagicaltuxMagicaltux
    Oct 29, 2007 at 6:28 am
    Aug 10, 2010 at 3:43 pm
  • In case of an empty identifier the function returns a warning, not the boolean 'false'. "Warning: timezone_open() [function.timezone-open]: Unknown or bad timezone () " ---- Server IP: 217.160.72.57 ...
    KayKay
    Oct 27, 2007 at 6:12 pm
    May 1, 2010 at 4:18 am
  • JOECOLE, isn't this the same thing? $str = mb_convert_case($str, MB_CASE_TITLE, "UTF-8"); ---- Server IP: 69.147.83.197 Probable Submitter: 216.145.54.7 ---- Manual Page -- ...
    TonyboydTonyboyd
    Oct 17, 2007 at 6:49 pm
    Apr 7, 2010 at 7:07 pm
  • http://www.fpdf.org/ is also quite good. Np lib install is required -Shelon Padmore ---- Server IP: 69.147.83.197 Probable Submitter: 190.6.231.26 ---- Manual Page -- ...
    Spadmore1980Spadmore1980
    Oct 23, 2007 at 10:22 pm
    Apr 7, 2010 at 7:03 pm
  • Interop Between PHP and Java URLs has changed to: http://propaso.com/blog/?p=7 (Part 4) it is linked to Part 1, 2 and 3. ---- Server IP: 69.147.83.197 Probable Submitter: 202.156.12.10 (proxied: ...
    LinusyongLinusyong
    Oct 6, 2007 at 11:14 am
    Apr 7, 2010 at 4:38 pm
  • I enhance xml2array (can't remember who author) to work with duplicate key index by change "tagData" function with this - <? function tagData($parser, $tagData) { // set the latest open tag equal to ...
    TeerachaijTeerachaij
    Oct 15, 2007 at 9:14 am
    Mar 3, 2010 at 6:38 pm
  • To add to Stephen's note about logging, I found that if I defined the error_log path to be the Apache error log folder (ie: /var/log/httpd/php_error_log), it would still log to Apache's log, not the ...
    MikeMike
    Oct 11, 2007 at 7:51 am
    Feb 18, 2010 at 2:20 pm
Group Navigation
period‹ prev | Oct 2007 | next ›
Group Overview
groupphp-notes @
categoriesphp
discussions666
posts925
users532
websitephp.net

532 users for October 2007

Nlopess: 146 posts Ezyang: 49 posts James: 30 posts Tularis: 28 posts : 20 posts Anonymous: 18 posts Hayleywatson: 14 posts Webmaster: 10 posts Packard_bell_nec: 8 posts Andersjenbopcdk: 7 posts Scottfromezyauctionz Co Nz: 6 posts Petruzanauticoyahoo?com!ar: 4 posts Jani: 4 posts Prasankn: 4 posts Perching_eagle: 4 posts Bjori: 3 posts Vasilrangelov: 3 posts Phpdoc: 3 posts Vha: 3 posts Bikinyboy: 3 posts
show more
Archives