Php-application instance-Bubble Sorting

Source: Internet
Author: User
Tags comparison table glob mysql functions tidy variable scope wrappers

Php-application instance-Bubble Sorting [Source Code]


<?php

function bubble_sort($arr)

{

    $num = count($arr);

    $i ="";

    for($i=0; $i < $num;$i++)

    {

        $j ="";

        for($j= $i+1; $j < $num; $j++)

        {

            $temp = "";

            if ($arr[$i] > $arr[$j]) 

            {

                $temp = $arr[$i];

                $arr[$i] = $arr[$j];

                $arr[$j] = $temp;

            }                

        }

    }

    return $arr;

}

function test_bubble_sort ()

{

    $size = 10;

    for($i = 0; $i < $size; $i++) {

        $source[] = rand();

    }

    $bubble_result = bubble_sort($source);

    $sort_result = $source;

    sort($sort_result);

    return $bubble_result === $sort_result;

}

var_dump(test_bubble_sort());

?>


[PHP-Official Website]

Http://www.php.net/

[PHP-keywords]

PHP
PDT

[PHP-related forums]

Http://php.board.newsmth.net/
Http://homepage.bdwm.net/
Http://forum.csdn.net/SList/PHP/

[PHP-download]

Appserv
2.5.9, http://www.appservnetwork.com/

Zend
Optimizer 3.3.0a, http://www.zend.com/products/zend_optimizer

PhpMyAdmin
2.11.2, http://www.phpmyadmin.net/home_page/index.php

Zend
Core 2.5.0 http://www.zend.com/products/zend_core

Zend
Platform 3.0.3, http://www.zend.com/products/zend_platform

PHP
5.2.5 http://www.php.net/releases/5_2_5.php

Zend
Studio 5.5, http://www.zend.com/products/zend_studio

Zend
Guard 5.0, http://www.zend.com/products/zend_guard

PDT project 1.0.3, http://www.eclipse.org/pdt/

[PHP-manual]

Http://www.php.net/manual/


[PHP-xoops]

Http://xoops.org.cn/

[PHP-phpBB]

Http://www.phpbbchina.com/


[PHP-manual]

File_exists: Check whether a file or directory exists,

Http://www.php.net/manual/zh/function.file-exists.php


[PHP-manual-download]

Http://www.php.net/download-docs.php

[PHP-manual-Language Reference-type]

String to numeric value,
Http://www.php.net/manual/zh/language.types.string.php#language.types.string.conversion

[PHP-manual-Language Reference-variables variable]

Variable scope variable visibility, http://www.php.net/manual/en/language.variables.scope.php

[PHP-manual-Chapter 1 constants]

Magic constant,

Http://www.php.net/manual/zh/language.constants.predefined.php

[PHP-manual-Language Reference-operator]

Error Control operator,

Http://www.php.net/manual/zh/language.operators.errorcontrol.php

Bitwise operator,
Http://www.php.net/manual/zh/language.operators.bitwise.php

[PHP-manual-Language Reference-control structure]

Foreach traverses the array,

Http://www.php.net/manual/zh/control-structures.foreach.php

[PHP-manual-Language Reference-class and object (PHP 5)]

Object
Cloning object clone, http://www.php.net/manual/zh/language.oop5.cloning.php

Class
Abstract action class,
Http://www.php.net/manual/zh/language.oop5.abstract.php

[PHP-manual-Chapter 20th Exception Handling]

Overview,

Http://www.php.net/manual/zh/language.exceptions.php

PHP improvement process with Exception Handling

[PHP-manual-Chapter 21st references]

Returns a reference,

Http://www.php.net/manual/zh/language.references.return.php

[PHP-manual-features-php Command Line Mode]

PHP
Command Line Mode, http://www.php.net/manual/zh/features.commandline.php

Table
43.2. Dedicated CLI constants,

Http://www.php.net/manual/zh/features.commandline.php#id2715646

[PHP-manual-V. array functions]

Calculates the intersection of arrays,
Http://www.php.net/manual/zh/function.array-intersect.php

Array_merge combines one or more arrays,

Http://www.php.net/manual/zh/function.array-merge.php

Reset points the internal pointer of the array to the first unit,

Http://www.php.net/manual/zh/function.reset.php

[PHP-manual-xviii. Curl, client URL library function]

Overview,

Http://www.php.net/manual/zh/ref.curl.php

Curl_setopt sets the curl transfer option,

Http://www.php.net/manual/zh/function.curl-setopt.php

[PHP-manual-xxii. date/time function]

Format a local time/date,

Http://www.php.net/manual/zh/function.date.php

[PHP-manual-function reference-File System related extensions file system-directories directory-directory functions directory function]

Scandir lists the files and directories in the specified path, http://www.php.net/manual/en/function.scandir.php
[PHP-manual-function reference-File System
Related extensions-filesystem
Functions file system functions]

Fscanf format input from file, http://www.php.net/manual/en/function.fscanf.php
Glob get file name by mode, http://www.php.net/manual/en/function.glob.php
[PHP-manual-XXXIII. Error Handling and logging functions error handling and log functions]

Overview,
Http://www.php.net/manual/zh/ref.errorfunc.php

[PHP-manual-function reference-filesystem file system functions]

Is_uploaded_file
Http post uploaded, http://www.php.net/manual/zh/function.is-uploaded-file.php

Fgetcsv reads and parses a row from the file pointer
CSV field and http://www.php.net/manual/zh/function.fgetcsv.php

Is_dir checks whether the given file name is a directory,
Http://www.php.net/manual/zh/function.is-dir.php

Is_file determines whether a given file name is a normal file, http://www.php.net/manual/zh/function.is-file.php

[PHP-manual-XLVII. Function handling functions function management function]

Register_shutdown_function registers a function called when the script ends,

Http://www.php.net/manual/zh/function.register-shutdown-function.php

[PHP-manual-XC. miscellaneous functions]

Sleep delayed execution,

Http://www.php.net/manual/zh/ref.misc.php

Uniqid generates a unique ID,

Http://www.php.net/manual/zh/function.uniqid.php

[PHP-manual-function reference-Database
Extensions database extensions-Vendor Specific database extensions for specific providers-MySQL
-MySQL functions-mysql functions]

Mysql_real_escape_string escape special characters in the string used in the SQL statement, and take into account the current character set connected, http://www.php.net/manual/en/function.mysql-real-escape-string.php

[PHP-manual-CII. network functions]

Setcookie sends a cookie,

Http://www.php.net/manual/zh/function.setcookie.php

[PHP-manual-function reference-PHP options & Information-PHP options and information]

Extension_loaded queries whether to load the specified extension,

Http://www.php.net/manual/zh/function.extension-loaded.php

Load PHP extensions during DL running,

Http://www.php.net/manual/zh/function.dl.php

[PHP-manual-cxxvii. PostgreSQL database functions]

Pg_insert Insert the array into the table,

Http://www.php.net/manual/zh/index.php

[PHP-manual-CXXX. program execution functions program call function]

Proc_open: Execute the command and open the file pointer for input and output,

Http://www.php.net/manual/zh/function.proc-open.php

[PHP-manual-function reference-session
Extensions session extension-session handling session operation-installing/configuring installation/configuration-
Runtime configuration]

Session. save_path defines the parameters passed to the storage processor, http://cn.php.net/manual/en/session.configuration.php#ini.session.save-path

Session. use_only_cookies: Specifies whether to use only on the client
Cookie to store session IDs,

Http://www.php.net/manual/zh/ref.session.php#ini.session.use-only-cookies

[PHP-manual-function reference-soap functions-soap function]

Soap. wsdl_cache_enabled enables or disables the WSDL cache function,

Http://www.php.net/manual/zh/ref.soap.php#ini.soap.wsdl-cache-enabled

Soap
The SOAP configuration option is lost in the configuration options missing documentation document,

Http://bugs.php.net/bug.php? Id = 38644

[PHP-manual-function reference-Text Processing-strings string-string functions string function]

Str_pad uses another string to fill a string with the specified length,
Http://www.php.net/manual/zh/function.str-pad.php

Strpos searches for the position where a string appears for the first time,

Http://www.php.net/manual/zh/function.strpos.php

Substr returns part of the string,

Http://www.php.net/manual/zh/function.substr.php

Str_replace replaces all search strings with replacement strings,
Http://www.php.net/manual/zh/function.str-replace.php

Explode uses one string to separate another string, http://www.php.net/manual/zh/function.explode.php

Remove HTML and PHP tags in strip_tags strings, http://www.php.net/manual/en/function.strip-tags.php

[PHP-manual-function reference-other basic extensions-tidy]

Tidy functions-tidy function, http://www.php.net/manual/en/ref.tidy.php
[PHP-manual-clxvii. tokenizer FunctionsParser code function]

Tokenizer functions parser code function, http://www.php.net/manual/zh/ref.tokenizer.php

Token_get_all splits the given source code into the parser code,

Http://www.php.net/manual/zh/function.token-get-all.php

[PHP-manual-clxix. url function]

Overview,
Http://www.php.net/manual/zh/ref.url.php

[PHP-manual-function reference-variable and type related extensions variable and type-arrays array-array functions Array Function]

Ksort sorts the array by key name, http://www.php.net/manual/en/function.ksort.php

[PHP-manual-function reference-variable and
Type related extensions variables and type-related extensions-variable handling variable operation-Variable
Handling functions variable operation function]

Is_numeric checks whether the variable is a numeric or numeric string, http://www.php.net/manual/en/function.is-numeric.php

Serialize generates a representation of stored values,
Http://www.php.net/manual/zh/function.serialize.php

Settype sets the type of the variable, http://www.php.net/manual/zh/function.settype.php

[PHP-manual-clxxxvii. ZIP file functions-zip file compression function]

Overview,

Http://www.php.net/manual/zh/ref.zip.php

[PHP-manual-appendices appendix-PHP. ini directives-PHP. ini configuration options-Description of core PHP. ini directives describes core PHP. ini configuration options]

Register_globals
Determine whether to register egpcs (environment, get, post, Cookie, server) variables as global variables,
Http://www.php.net/manual/en/ini.core.php#ini.register-globals

Short_open_tag determines whether to allow the abbreviated form of the PHP code start sign,
Http://www.php.net/manual/zh/ini.core.php#ini.short-open-tag

PHP. ini core configuration option description-file_uploads, http://www.php.net/manual/zh/ini.core.php#ini.file-uploads

[PHP-manual-Appendix L. reserved word list]

Server variables: $ _ server,

Http://www.php.net/manual/zh/reserved.variables.php#reserved.variables.server

[PHP-manual-appendices appendix-List of protocols/encapsulation protocols supported by supported protocols/wrappers]

HTTP and https, http://www.php.net/manual/en/wrappers.http.php

[PHP-manual-Appendix Q. php type comparison table]

Table
Q.2. loose comparison with =,

Http://www.php.net/manual/zh/types.comparisons.php#id9240444

[PHP-application instance]

Syntax coloring: php.exe-s "% 1"> "cmd1.html"

Remove sub-objects from simplexml objects

24 o'clock

Nfo2image-nfo

Bubble Sorting

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.