< 1 2 3 4 5 6 7 > >>   Sort: Rank

Truncating an Array in PHP
How To Truncate an Array in PHP? If you want to remove a chunk of values from an array, you can use the array_splice($array, $offset, $length) function. $offset defines the starting position of the chunk to be removed. If $offset is positive, it is counted from the beginning of the array. If negativ...
2017-01-05, 343👍, 0💬

Joining Array Values into a Single String in PHP
How To Join Multiple Strings Stored in an Array into a Single String in PHP? If you multiple strings stored in an array, you can join them together into a single string with a given delimiter by using the implode() function. Here is a PHP script on how to use implode(): &lt;?php $date = array('0...
2017-01-05, 317👍, 0💬

Creating Your Own Functions in PHP
Where to find tutorials on how to create Your Own Functions in PHP? A collection of tutorials to answer many frequently asked questions on Creating Your Own Functions in PHP. Topics included in this collection are: Defining a User Function in PHP Invoking a User Function in PHP Returning a Value fro...
2016-12-28, 542👍, 0💬

Getting Minimum/Maximum Value of an Array in PHP
How To Get the Minimum or Maximum Value of an Array in PHP? If you want to get the minimum or maximum value of an array, you can use the min() or max() function. Here is a PHP script on how to use min() and max(): &lt;?php $array = array(5, 7, 6, 2, 1, 3, 4, 2); print("Minimum number: ".min($arr...
2016-12-28, 329👍, 0💬

Invoking a User Function in PHP
How To Invoke a User Function? in PHP? You can invoke a function by entering the function name followed by a pair of parentheses. If needed, function arguments can be specified as a list of expressions enclosed in parentheses. Here is a PHP script example on how to invoke a user function: &lt;?p...
2016-12-28, 326👍, 0💬

Defining a User Function in PHP
How To Define a User Function? in PHP? You can define a user function anywhere in a PHP script using the function statement like this: "function name() {...}". Here is a PHP script example on how to define a user function: &lt;?php function msg() { print("Hello world!\n"); } msg(); ?&gt; Thi...
2016-12-28, 322👍, 0💬

Splitting a String into an Array in PHP
How To Split a String into an Array of Substring in PHP? There are two functions you can use to split a string into an Array of Substring: explode(substring, string) - Splitting a string based on a substring. Faster than split(). split(pattern, string) - Splitting a string based on a regular express...
2016-12-28, 319👍, 0💬

Passing an Argument to a Function in PHP
How To Pass an Argument to a Function? in PHP? To pass an argument to a function, you need to: Add an argument definition in the function definition. Add a value as an argument when invoking the function. Here is a PHP script on how to use arguments in a function(): &lt;?php function f2c($f) { r...
2016-12-24, 360👍, 0💬

Defining an Argument as a Reference in PHP
Can You Define an Argument as a Reference Type? in PHP? You can define an argument as a reference type in the function definition. This will automatically convert the calling arguments into references. Here is a PHP script on how to define an argument as a reference type: &lt;?php function ref_s...
2016-12-24, 350👍, 0💬

Passing Variables by References in PHP
How To Pass Variables By References? in PHP? You can pass a variable by reference to a function by taking the reference of the original variable, and passing that reference as the calling argument. Here is a PHP script on how to use pass variables by references: &lt;?php function swap($a, $b) { ...
2016-12-24, 310👍, 0💬

Returning a Value from a Function in PHP
How To Return a Value Back to the Function Caller? in PHP? You can return a value to the function caller by using the "return $value" statement. Execution control will be transferred to the caller immediately after the return statement. If there are other statements in the function after the return ...
2016-12-24, 308👍, 0💬

Variables Are Passed by Values in PHP
How Variables Are Passed Through Arguments? in PHP? Like more of other programming languages, variables are passed through arguments by values, not by references. That means when a variable is passed as an argument, a copy of the value will be passed into the function. Modifying that copy inside the...
2016-12-24, 300👍, 0💬

Defining an Array Argument as Reference in PHP
Can You Define an Array Argument as a Reference Type? in PHP? You can define an array argument as a reference type in the function definition. This will automatically convert the calling arguments into references. Here is a PHP script on how to define an array argument as a reference type: &lt;?...
2016-12-18, 341👍, 0💬

Passing Arrays to Function in PHP
Can You Pass an Array into a Function? in PHP? You can pass an array into a function in the same as a normal variable. No special syntax needed. Here is a PHP script on how to pass an array to a function: &lt;?php function average($array) { $sum = array_sum($array); $count = count($array); retur...
2016-12-18, 331👍, 0💬

Passing Arrays by Values to Functions in PHP
How Arrays Are Passed Through Arguments? in PHP? Like a normal variable, an array is passed through an argument by value, not by reference. That means when an array is passed as an argument, a copy of the array will be passed into the function. Modifying that copy inside the function will not impact...
2016-12-18, 305👍, 0💬

Returning an Array from a Function in PHP
How To Return an Array from a Function? in PHP? You can return an array variable like a normal variable using the return statement. No special syntax needed. Here is a PHP script on how to return an array from a function: &lt;?php function powerBall() { $array = array(rand(1,55), rand(1,55), ran...
2016-12-18, 302👍, 0💬

Passing Arrays by References to Functions in PHP
How To Pass Arrays By References? in PHP? Like normal variables, you can pass an array by reference into a function by taking a reference of the original array, and passing the reference to the function. Here is a PHP script on how to pass array as reference: &lt;?php function shrink($array) { a...
2016-12-18, 296👍, 0💬

Returning a Reference from a Function in PHP
How To Return a Reference from a Function? in PHP? To return a reference from a function, you need to: Add the reference operator "&amp;" when defining the function. Add the reference operator "&amp;" when invoking the function. Here is a PHP script on how to return a reference from a functi...
2016-12-08, 495👍, 0💬

Local Variables in a Function in PHP
What Is the Scope of a Variable Defined in a Function? in PHP? The scope of a local variable defined in a function is limited with that function. Once the function is ended, its local variables are also removed. So you can not access any local variable outside its defining function. Here is a PHP sc...
2016-12-08, 335👍, 0💬

Accessing Global Variables inside a Function in PHP
How To Access a Global Variable inside a Function? in PHP? By default, global variables are not accessible inside a function. However, you can make them accessible by declare them as "global" inside a function. Here is a PHP script on declaring "global" variables: &lt;?php ?&gt; $intRate = 5...
2016-12-08, 332👍, 0💬

Function Returns Data by Value in PHP
How Values Are Returned from Functions? in PHP? If a value is returned from a function, it is returned by value, not by reference. That means that a copy of the value is return. Here is a PHP script on how values are returned from a function: &lt;?php $favor = "vbulletin"; function getFavor() { ...
2016-12-08, 327👍, 0💬

Global Variables in Main Script in PHP
What Is the Scope of a Variable Defined outside a Function? in PHP? A variable defined outside any functions in main script body is called global variable. However, a global variable is not really accessible globally any in the script. The scope of global variable is limited to all statements outsid...
2016-12-08, 305👍, 0💬

Reading and Writing Files in PHP
Where to find tutorials on how to Read and Write Files in PHP? A collection of tutorials to answer many frequently asked questions how to Read and Write Files in PHP. Topics included in this collection are: Reading a Text File to an Array in PHP Reading the Entire File to a String in PHP Opening a f...
2016-12-04, 561👍, 0💬

Specifying Argument Default Values in PHP
How To Specify Argument Default Values? in PHP? If you want to allow the caller to skip an argument when calling a function, you can define the argument with a default value when defining the function. Adding a default value to an argument can be done like this "function name($arg=expression){}. Her...
2016-12-04, 544👍, 0💬

< 1 2 3 4 5 6 7 > >>   Sort: Rank