Results of 1 - 10 of about 41 for fruits (0.002 sec.)
- sort — 配列を昇順にソートする | PHP 8.3 14112
- 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
- DOMNode::getNodePath — ノードの XPath を取得する | PHP 8.3 12014
- DOMNode::getNodePath (PHP 5 >= 5.2.0, PHP 7, PHP 8) DOMNode::getNodePath — ノードの XPath を取得する 説明 public function DOMNode::getNodePath (): ? string ノードの XPath ロケーションパスを取得します。 パラメータ この関数にはパラメータはあり
... の例 <?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 他のマニュア ...
-
https://man.mtool.work/php/8.3/domnode.getnodepath.html
- libxml のエラー処理関数によるエラー処理 | PHP 8.3 11035
- libxml のエラー処理関数によるエラー処理 libxml にはエラー処理用の関数が用意されており、これらを使うと、 XSLT の処理中のエラーを捕らえて対応できます。 例1 fruits.xml 妥当な XML ファイルです。 <fruits> <fruit>Apple</fruit> <fruit>Banana</frui
... t> <fruit>Cherry</fruit> </fruits> 例2 fruits.xsl 無効な select 式が含まれています。 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Tra ... nsform"> <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
- 例 | PHP 8.3 9745
- 例 例1 Random の例 <?php $r = new \Random\Randomizer (); // ランダムなドメイン名を生成する printf ( "%s.example.com\n" , $r -> getBytesFromString ( 'abcdefghijklmnopqrstuvwxyz0123456789' , 16 ) ); // 配列をシャッフルする: $fruits = [ 'red'
... een' => '?' , '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
- usort — ユーザー定義の比較関数を使用して、配列を値でソートする | PHP 8.3 9092
- usort (PHP 4, PHP 5, PHP 7, PHP 8) usort — ユーザー定義の比較関数を使用して、配列を値でソートする 説明 function usort ( array &$array , callable $callback ): true 順序を決めるユーザー定義の比較関数により、 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
- Random\Randomizer::pickArrayKeys — ランダムに配列のキーを選択する | PHP 8.3 8952
- Random\Randomizer::pickArrayKeys (PHP 8 >= 8.2.0) Random\Randomizer::pickArrayKeys — ランダムに配列のキーを選択する 説明 public function Random\Randomizer::pickArrayKeys ( array $array , int $num ): array 指定された array に存在する、 num 個
... あらゆる 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
- Pdo\Pgsql::copyFromFile — ファイルからデータをテーブルにコピーする | PHP 8.3 8688
- Pdo\Pgsql::copyFromFile (PHP 8 >= 8.4.0) Pdo\Pgsql::copyFromFile — ファイルからデータをテーブルにコピーする 説明 public function Pdo\Pgsql::copyFromFile ( string $tableName , string $filename , string $separator = "\t" , string $nullAs = "\
... st' , $user , $pass ); $db -> setAttribute ( PDO :: ATTR_ERRMODE , PDO :: ERRMODE_EXCEPTION ); $db -> exec ( 'CREATE TABLE fruits (id int, name text, qty int)' ); file_put_contents ( '/tmp/fruits.tsv' , "1\tapple\t10\n2\tbanana\t20\n" ); $db -> copyFro ... mFile ( 'fruits' , '/tmp/fruits.tsv' ); echo $db -> query ( 'SELECT count(*) FROM fruits' )-> fetchColumn (), "\n" ; ?> 上の例の出力は以下 ...
-
https://man.mtool.work/php/8.3/pdo-pgsql.copyfromfile.html
- Pdo\Pgsql::copyToFile — テーブルのデータをファイルにコピーする | PHP 8.3 8626
- Pdo\Pgsql::copyToFile (PHP 8 >= 8.4.0) Pdo\Pgsql::copyToFile — テーブルのデータをファイルにコピーする 説明 public function Pdo\Pgsql::copyToFile ( string $tableName , string $filename , string $separator = "\t" , string $nullAs = "\\\\N" ,
... st' , $user , $pass ); $db -> setAttribute ( PDO :: ATTR_ERRMODE , PDO :: ERRMODE_EXCEPTION ); $db -> exec ( 'CREATE TABLE fruits (id int, name text, qty int)' ); $db -> exec ( "INSERT INTO fruits VALUES (1, 'apple', 10), (2, 'banana', 20)" ); $db -> c ... opyToFile ( 'fruits' , '/tmp/fruits.tsv' ); echo file_get_contents ( '/tmp/fruits.tsv' ); ?> 上の例の出力は以下となります。 1 apple 10 2 banan ...
-
https://man.mtool.work/php/8.3/pdo-pgsql.copytofile.html
- array_walk_recursive — 配列の全ての要素に、ユーザー関数を再帰的に適用する | PHP... 8299
- array_walk_recursive (PHP 5, PHP 7, PHP 8) array_walk_recursive — 配列の全ての要素に、ユーザー関数を再帰的に適用する 説明 function array_walk_recursive ( array | object &$array , callable $callback , mixed $arg = null ): true array 配列の各
... バージョンでは、 bool でした。 例 例1 array_walk_recursive() の例 <?php $sweet = array( 'a' => 'apple' , 'b' => 'banana' ); $fruits = array( 'sweet' => $sweet , 'sour' => 'lemon' ); function test_print ( $item , $key ) { echo " $key holds $item \n" ; } a ... rray_walk_recursive ( $fruits , 'test_print' ); ?> 上の例の出力は以下となります。 a holds apple b holds banana sour holds lemon キー ' sweet ' が表示され ... ve() で値をその場で更新することもできます。 例2 値をその場で更新する <?php $sweet = [ 'a' => 'apple' , 'b' => 'banana' ]; $fruits = [ 'sweet' => $sweet , 'sour' => 'lemon' ]; function test_update (& $item ) { $item = strtoupper ( $item ); } function te ...
-
https://man.mtool.work/php/8.3/function.array-walk-recursive.html
- arsort — 連想キーと要素との関係を維持しつつ配列を降順にソートする | PHP 8.3 7849
- arsort (PHP 4, PHP 5, PHP 7, PHP 8) arsort — 連想キーと要素との関係を維持しつつ配列を降順にソートする 説明 function arsort ( array &$array , int $flags = SORT_REGULAR ): true 各配列のキーと要素との関係を維持しつつ、 array を降順にソートしま
... ージョン 説明 8.2.0 戻り値の型が、 true になりました。これより前のバージョンでは、 bool でした。 例 例1 arsort() の例 <?php $fruits = array( "d" => "lemon" , "a" => "orange" , "b" => "banana" , "c" => "apple" ); arsort ( $fruits ); foreach ( $fruits as $ ... key => $val ) { echo " $key = $val \n" ; } ?> 上の例の出力は以下となります。 a = orange d = lemon b = banana c = apple fruits はアルファベットの降順にソートされ、 各要素とキーとの関係は維持されます。 参考 sort() - 配列を昇順にソートする asort() - 連 ...
-
https://man.mtool.work/php/8.3/function.arsort.html