« PHP 8.3 Manual トップ
著作権 »
per page, with , order by , clip by
Results of 1 - 10 of about 83 for fruits (0.003 sec.)
配列を昇順にソートする 11914
« sizeof uasort » PHP Manual 配列 関数 配列を昇順にソートする 検索 sort (PHP 4, PHP 5, PHP 7, PHP 8) sort — 配列を昇順にソートする 説明 function sort ( array &$array , int $flags = SORT_REGULAR ): true array を値で昇順にソートします。 注意 ... バージョン 説明 8.2.0 戻り値の型が、 true になりました。これより前のバージョンでは、 bool でした。 例 例1 sort() の例 <?php $fruits = array( "lemon" , "orange" , "banana" , "apple" ); sort ( $fruits ); foreach ( $fruits as $key => $val ) { echo "fruits[" ... . $key . "] = " . $val . "\n" ; } ?> 上の例の出力は以下となります。 fruits[0] = apple fruits[1] = banana fruits[2] = lemon fruits[3] = orange fruits はアルファベットの昇順にソートされました。 例2 s ... ort() で、大文字小文字を区別せずに自然順での並べ替えを行う例 <?php $fruits = array( "Orange1" , "orange2" , "Orange3" , "orange20" ); sort ( $fruits , SORT_NATURAL | SORT_FLAG_CASE ); foreach ( $fr ...
https://man.mtool.work/php/8.3/function.sort.html
配列を昇順にソートする 11914
« sizeof uasort » PHP Manual 配列 関数 配列を昇順にソートする 検索 sort (PHP 4, PHP 5, PHP 7, PHP 8) sort — 配列を昇順にソートする 説明 function sort ( array &$array , int $flags = SORT_REGULAR ): true array を値で昇順にソートします。 注意 ... バージョン 説明 8.2.0 戻り値の型が、 true になりました。これより前のバージョンでは、 bool でした。 例 例1 sort() の例 <?php $fruits = array( "lemon" , "orange" , "banana" , "apple" ); sort ( $fruits ); foreach ( $fruits as $key => $val ) { echo "fruits[" ... . $key . "] = " . $val . "\n" ; } ?> 上の例の出力は以下となります。 fruits[0] = apple fruits[1] = banana fruits[2] = lemon fruits[3] = orange fruits はアルファベットの昇順にソートされました。 例2 s ... ort() で、大文字小文字を区別せずに自然順での並べ替えを行う例 <?php $fruits = array( "Orange1" , "orange2" , "Orange3" , "orange20" ); sort ( $fruits , SORT_NATURAL | SORT_FLAG_CASE ); foreach ( $fr ...
https://man.mtool.work/php/8.3/function.sort.html
ノードの XPath を取得する 10515
« DOMNode::getLineNo DOMNode::getRootNode » PHP Manual DOMNode ノードの XPath を取得する 検索 DOMNode::getNodePath (PHP 5 >= 5.2.0, PHP 7, PHP 8) DOMNode::getNodePath — ノードの XPath を取得する 説明 public function DOMNode::getNodePath (): ... の例 <?php // 新しい DOMDocument インスタンスを作ります $dom = new DOMDocument ; // XML を読み込みます $dom -> loadXML ( ' <fruits> <apples> <apple>braeburn</apple> <apple>granny smith</apple> </apples> <pears> <pear>conference</pear> </pears> </fruits> ... om -> getElementsByTagName ( '*' ) as $node ) { echo $node -> getNodePath () . "\n" ; } ?> 上の例の出力は以下となります。 /fruits /fruits/apples /fruits/apples/apple[1] /fruits/apples/apple[2] /fruits/pears /fruits/pears/pear 参考 DOMXPath 関連キーワー ... ド: fruits DOMNode XPath apple getNodePath apples ノード pears dom pear パラメータ DOMDocument node getLineNo Search getRootNode func ...
https://man.mtool.work/php/8.3/domnode.getnodepath.html
ノードの XPath を取得する 10460
« DOMNode::getLineNo DOMNode::getRootNode » PHP Manual DOMNode ノードの XPath を取得する 検索 DOMNode::getNodePath (PHP 5 >= 5.2.0, PHP 7, PHP 8) DOMNode::getNodePath — ノードの XPath を取得する 説明 public function DOMNode::getNodePath (): ... の例 <?php // 新しい DOMDocument インスタンスを作ります $dom = new DOMDocument ; // XML を読み込みます $dom -> loadXML ( ' <fruits> <apples> <apple>braeburn</apple> <apple>granny smith</apple> </apples> <pears> <pear>conference</pear> </pears> </fruits> ... om -> getElementsByTagName ( '*' ) as $node ) { echo $node -> getNodePath () . "\n" ; } ?> 上の例の出力は以下となります。 /fruits /fruits/apples /fruits/apples/apple[1] /fruits/apples/apple[2] /fruits/pears /fruits/pears/pear 参考 DOMXPath 関連キーワー ... ド: fruits DOMNode XPath apple getNodePath apples ノード pears pear DOMDocument node getLineNo getRootNode ロケーションパス インスタン ...
https://man.mtool.work/php/8.3/domnode.getnodepath.html
libxml のエラー処理関数によるエラー処理 9577
« collection.xml および collection.xsl ファイルの例 XSLTProcessor » PHP Manual 例 libxml のエラー処理関数によるエラー処理 検索 libxml のエラー処理関数によるエラー処理 libxml にはエラー処理用の関数が用意されており、これらを使うと、 XSLT の処 ... 理中のエラーを捕らえて対応できます。 例1 fruits.xml 妥当な XML ファイルです。 <fruits> <fruit>Apple</fruit> <fruit>Banana</fruit> <fruit>Cherry</fruit> </fruits> 例2 frui ... :xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html" encoding="utf-8" indent="no"/> <xsl:template match="fruits"> <ul> <xsl:apply-templates/> </ul> </xsl:template> <xsl:template match="fruit"> <li><xsl:value-of select="THIS IS A DELIB ... です。 <?php $xmldoc = new DOMDocument (); $xsldoc = new DOMDocument (); $xsl = new XSLTProcessor (); $xmldoc -> loadXML ( 'fruits.xml' ); $xsldoc -> loadXML ( 'fruits.xsl' ); libxml_use_internal_errors ( true ); $result = $xsl -> importStyleSheet ( $xs ...
https://man.mtool.work/php/8.3/xsl.examples-errors.html
libxml のエラー処理関数によるエラー処理 9577
« collection.xml および collection.xsl ファイルの例 XSLTProcessor » PHP Manual 例 libxml のエラー処理関数によるエラー処理 検索 libxml のエラー処理関数によるエラー処理 libxml にはエラー処理用の関数が用意されており、これらを使うと、 XSLT の処 ... 理中のエラーを捕らえて対応できます。 例1 fruits.xml 妥当な XML ファイルです。 <fruits> <fruit>Apple</fruit> <fruit>Banana</fruit> <fruit>Cherry</fruit> </fruits> 例2 frui ... :xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html" encoding="utf-8" indent="no"/> <xsl:template match="fruits"> <ul> <xsl:apply-templates/> </ul> </xsl:template> <xsl:template match="fruit"> <li><xsl:value-of select="THIS IS A DELIB ... です。 <?php $xmldoc = new DOMDocument (); $xsldoc = new DOMDocument (); $xsl = new XSLTProcessor (); $xmldoc -> loadXML ( 'fruits.xml' ); $xsldoc -> loadXML ( 'fruits.xsl' ); libxml_use_internal_errors ( true ); $result = $xsl -> importStyleSheet ( $xs ...
https://man.mtool.work/php/8.3/xsl.examples-errors.html
例 8681
« 定義済み定数 Random 関数 » PHP Manual Random 例 検索 例 例1 Random の例 <?php $r = new \Random\Randomizer (); // ランダムなドメイン名を生成する printf ( "%s.example.com\n" , $r -> getBytesFromString ( 'abcdefghijklmnopqrstuvwxyz0123456789 ... ' , 16 ) ); // 配列をシャッフルする: $fruits = [ 'red' => '?' , 'green' => '?' , 'yellow' => '?' , 'pink' => '?' , 'purple' => '?' ]; echo "Salad: " , implode ( ', ' , ... $r -> shuffleArray ( $fruits )), "\n" ; // 配列のキーをシャッフルする $fruits = [ 'red' => '?' , 'green' => '?' , 'yellow' => '?' , 'pink' => '?' , 'pu ... rple' => '?' ]; $keys = $r -> pickArrayKeys ( $fruits , 2 ); // 選択したキーの値を調べる $selection = array_map ( static fn ( $key ) => $fruits [ $key ], $keys ); echo "Values: ...
https://man.mtool.work/php/8.3/random.examples.html
例 8626
« 定義済み定数 Random 関数 » PHP Manual Random 例 検索 例 例1 Random の例 <?php $r = new \Random\Randomizer (); // ランダムなドメイン名を生成する printf ( "%s.example.com\n" , $r -> getBytesFromString ( 'abcdefghijklmnopqrstuvwxyz0123456789 ... ' , 16 ) ); // 配列をシャッフルする: $fruits = [ 'red' => '?' , 'green' => '?' , 'yellow' => '?' , 'pink' => '?' , 'purple' => '?' ]; echo "Salad: " , implode ( ', ' , ... $r -> shuffleArray ( $fruits )), "\n" ; // 配列のキーをシャッフルする $fruits = [ 'red' => '?' , 'green' => '?' , 'yellow' => '?' , 'pink' => '?' , 'pu ... rple' => '?' ]; $keys = $r -> pickArrayKeys ( $fruits , 2 ); // 選択したキーの値を調べる $selection = array_map ( static fn ( $key ) => $fruits [ $key ], $keys ); echo "Values: ...
https://man.mtool.work/php/8.3/random.examples.html
ランダムに配列のキーを選択する 7893
« Random\Randomizer::nextInt Random\Randomizer::__serialize » PHP Manual Random\Randomizer ランダムに配列のキーを選択する 検索 Random\Randomizer::pickArrayKeys (PHP 8 >= 8.2.0) Random\Randomizer::pickArrayKeys — ランダムに配列のキーを選択す ... あらゆる Throwable がスローされます。 例 例1 Random\Randomizer::pickArrayKeys() の例 <?php $r = new \Random\Randomizer (); $fruits = [ 'red' => '?' , 'green' => '?' , 'yellow' => '?' , 'pink' => '?' , 'purple' => '?' ]; // 配列のキーをふたつ、ランダムに ... 取り出します echo "Keys: " , implode ( ', ' , $r -> pickArrayKeys ( $fruits , 2 )), "\n" ; // 別の配列のキーを3つ取り出します echo "Keys: " , implode ( ', ' , $r -> pickArrayKeys ( $fruits , 3 )), " ... になります。 Keys: yellow, purple Keys: red, green, yellow 例2 ランダムに値を取り出す <?php $r = new \Random\Randomizer (); $fruits = [ 'red' => '?' , 'green' => '?' , 'yellow' => '?' , 'pink' => '?' , 'purple' => '?' ]; $keys = $r -> pickArrayKeys ( $fr ...
https://man.mtool.work/php/8.3/random-randomizer.pickarraykeys.html
ユーザー定義の比較関数を使用して、配列を値でソートする 7838
« uksort クラス/オブジェクト » PHP Manual 配列 関数 ユーザー定義の比較関数を使用して、配列を値でソートする 検索 usort (PHP 4, PHP 5, PHP 7, PHP 8) usort — ユーザー定義の比較関数を使用して、配列を値でソートする 説明 function usort ( array &$ ... 例2 多次元配列を使用する usort() の例 <?php function cmp ( $a , $b ) { return strcmp ( $a [ "fruit" ], $b [ "fruit" ]); } $fruits [ 0 ][ "fruit" ] = "lemons" ; $fruits [ 1 ][ "fruit" ] = "apples" ; $fruits [ 2 ][ "fruit" ] = "grapes" ; usort ( $fruits ... , "cmp" ); foreach ( $fruits as $key => $value ) { echo "\$fruits[ $key ]: " . $value [ "fruit" ] . "\n" ; } ?> 上の例の出力は以下となります。 $fruits[ ... 0]: apples $fruits[1]: grapes $fruits[2]: lemons 多次元配列をソートする際には、 $a と $b は配列の最初のインデックスへの参照を保持しています。 ...
https://man.mtool.work/php/8.3/function.usort.html
PREV 1 2 3 4 5 6 7 8 9 NEXT