タグ

ブックマーク / www.php.net (10)

  • PHP: asort - Manual

    配列のキーと要素との関係を維持しつつ、 array を昇順にソートします。 この関数は、 主に実際の要素の並び方が重要である連想配列をソートするために使われます。 注意: 比較結果が等しくなる二つの要素があった場合、それらの並び順は保持されます。PHP 8.0.0 より前のバージョンでは、ソートした配列におけるそれらの並び順は不定でした。 注意: この関数をコールすると、配列の内部ポインタは最初の要素にリセットされます。 パラメータ array 入力の配列。 flags オプションの第二引数 flags によりソートの動作を修正可能です。 使える値は下記の通りです: ソートタイプのフラグ: SORT_REGULAR - 通常通りに項目を比較します。 詳細は 比較演算子 で説明されています。 SORT_NUMERIC - 数値として項目を比較します。 SORT_STRING - 文字列として

    zuborawka
    zuborawka 2016/08/07
    はまってしまった・・・“比較結果が等しくなる二つのメンバーがあった場合、ソートした配列におけるそれらの並び順は未定義となります”
  • PHP: switch - Manual

    switch (PHP 4, PHP 5, PHP 7, PHP 8) switch文は、同じ式を用いてIF文を並べたのに似ています。 同じ変数を異なる値と比較し、値に応じて異なったコードを実行したいと 思うことがしばしばあるかと思います。 switch文は、まさにこのためにあるのです。 注意: 他の言語とは違って、 continue命令は switch にも適用され、breakと同じ動作をします。 ループの内部で switch を使用しており、 外側のループの処理を続行させたい場合には、continue 2 を使用してください。 注意: switch/case が行うのは、 緩やかな比較 であることに注意しましょう。 次の二つの例は、同じことを二つの異なった方法で書いたものです。 一つは、if と elseif文を、 もう一つはswitch文を使っています。 どちらも、出力は同じです。

    PHP: switch - Manual
    zuborawka
    zuborawka 2014/09/07
    “ 他の言語とは違って、 continue命令は switchにも適用され、breakと同じ動作をします。 ループの内部でswitchを使用しており、 外側のループの処理を続行させたい場合には、continue 2 を使用してください。”
  • PHP: bccomp - Manual

    Getting Started Introduction A simple tutorial Language Reference Basic syntax Types Variables Constants Expressions Operators Control Structures Functions Classes and Objects Namespaces Enumerations Errors Exceptions Fibers Generators Attributes References Explained Predefined Variables Predefined Exceptions Predefined Interfaces and Classes Predefined Attributes Context options and parameters Su

    zuborawka
    zuborawka 2014/02/13
    浮動小数点の比較
  • PHP: BC Math - Manual

    Useful function for bcround function getBcRound($number, $precision = 0) { $precision = ($precision < 0) ? 0 : (int) $precision; if (strcmp(bcadd($number, '0', $precision), bcadd($number, '0', $precision+1)) == 0) { return bcadd($number, '0', $precision); } if (getBcPresion($number) - $precision > 1) { $number = getBcRound($number, $precision + 1); } $t = '0.' . str_repeat('0', $precision) . '5';

  • PHP: 浮動小数点数 - Manual

    Getting Started Introduction A simple tutorial Language Reference Basic syntax Types Variables Constants Expressions Operators Control Structures Functions Classes and Objects Namespaces Enumerations Errors Exceptions Fibers Generators Attributes References Explained Predefined Variables Predefined Exceptions Predefined Interfaces and Classes Predefined Attributes Context options and parameters Su

    PHP: 浮動小数点数 - Manual
    zuborawka
    zuborawka 2013/10/11
    “float の比較”
  • PHP: オブジェクトのシリアライズ - Manual

    オブジェクトのシリアライズ - セッション内でのオブジェクト serialize() は、 PHP で保存できるあらゆる値をバイトストリームで表した文字列を返します。 unserialize() を使うと、 この文字列から元の変数の値を取り出すことができます。 オブジェクトをシリアライズすると、オブジェクト内の変数もすべて保存されます。 オブジェクト内のメソッドは保存されません。 クラス名のみが保存されます。 オブジェクトを unserialize() するには、 そのオブジェクトのクラスが定義されている必要があります。 A クラスのオブジェクトをシリアライズしたのなら、 その文字列にはクラス A とその中のすべての変数の値が含まれています。 別のファイルでそれを復元してクラス A のオブジェクトを取り出すには、 まずそのファイル内にクラス A の定義が存在しなければなりません。 これを実

    PHP: オブジェクトのシリアライズ - Manual
    zuborawka
    zuborawka 2013/09/28
    __PHP_Incomplete_Class_Name の発生理由。シリアル化したオブジェクトを再利用するときには、その時点でクラス定義が存在しなければならないのか。なるほど。
  • PHP: strpos - Manual

    Getting Started Introduction A simple tutorial Language Reference Basic syntax Types Variables Constants Expressions Operators Control Structures Functions Classes and Objects Namespaces Enumerations Errors Exceptions Fibers Generators Attributes References Explained Predefined Variables Predefined Exceptions Predefined Interfaces and Classes Predefined Attributes Context options and parameters Su

    PHP: strpos - Manual
    zuborawka
    zuborawka 2013/06/04
    $haystack と $needle の順番を何百回と間違えるんですよ。どうして in_array() とは逆なのは何故なんだぜ。
  • PHP: SimpleXML - Manual

    Here is a recursive function that will convert a given SimpleXMLElement object into an array, preserving namespaces and attributes. <?php function xmlObjToArr($obj) { $namespace = $obj->getDocNamespaces(true); $namespace[NULL] = NULL; $children = array(); $attributes = array(); $name = strtolower((string)$obj->getName()); $text = trim((string)$obj); if( strlen($text) <= 0 ) { $text = NULL; } // ge

    PHP: SimpleXML - Manual
    zuborawka
    zuborawka 2012/12/25
    simplexml で配列プロパティのノードを foreach で回すとキーが毎回同じ文字列なのはなぜなんだぜ?独自のイテレータ?
  • PHP - 型の比較表

    Getting Started Introduction A simple tutorial Language Reference Basic syntax Types Variables Constants Expressions Operators Control Structures Functions Classes and Objects Namespaces Enumerations Errors Exceptions Fibers Generators Attributes References Explained Predefined Variables Predefined Exceptions Predefined Interfaces and Classes Predefined Attributes Context options and parameters Su

    PHP - 型の比較表
    zuborawka
    zuborawka 2012/07/28
  • PHP: get_class_methods - Manual

    Getting Started Introduction A simple tutorial Language Reference Basic syntax Types Variables Constants Expressions Operators Control Structures Functions Classes and Objects Namespaces Enumerations Errors Exceptions Fibers Generators Attributes References Explained Predefined Variables Predefined Exceptions Predefined Interfaces and Classes Predefined Attributes Context options and parameters Su

    zuborawka
    zuborawka 2012/07/19
    結果がメソッドの可視性に応じて変化する。※オブジェクト自身からは、private method が見える
  • 1