PHP semantics dynamics: array to string - data history and one given

Modern ideas about data and variables, the type of which can only be determined at the time of use, allow you to use just variables and just arrays.

Numbers are usually separated into another category, in which mathematical functions and the syntax of arithmetic operations dominate. Objects are more complex constructs than arrays.

This is the basic data model that the algorithm processes.

Classic data and datasets

A variable has a name and a value. An array is characterized by many variables, not necessarily of the same type. A variable can change its type as necessary. Array elements may have a name, not an index. Such an array is called associative.

Classical programming, even when the algorithm uses objects, does not take into account the time factor. Time is a given that is used in processing. Meanwhile, any algorithm is executed over time. That is, at every moment of time, variables, arrays and objects change their values, types and properties.

Classic use of strings and arrays




In this example, a simple array of three elements was created, which the implode function merged into one line. The echo statement showed this. Trying to simply output the array resulted in a PHP array to string conversion error. Programming to this day has flaws that have long been fairly obvious, but so far the revolution has occurred only in the types of variables.





Now it is not necessary to describe the variable strictly before use and indicate its type.

The classic relationship between strings and arrays

PHP is a progressive and evolving programming language with a huge army of developers and fans. Many instrumental additions have been developed and are constantly being created for him, and he carefully absorbs all the best.

PHP is a progressive language




The main data transformation in PHP: array to string and vice versa: explode () / implode ().

Both functions have two parameters and one result. The first parameter is always a separator, the second is a string or array. If we are talking about explode (), then the string is split by the separator into the result - an array. If we are talking about implode (), then the array merges (different types of elements - it does not matter) into the result - a string.

At the same time, by executing in PHP array to string one separator, you can parse a string back into an array using another separator. PHP does not limit the imagination of the developer, it is enough to observe the syntax of the language, and how to deal with the semantics of operations is a matter of technology.

Time Factor: Variables and Algorithms

Classical semantics - information processing. There are variables and arrays. In an abstract sense, there is information in one form or another, which is presented in a clear data structure and algorithms for their processing.

Time Factor and Variables




With this concept, the time factor is lost. One variable changes during the execution of the algorithm. The history of its changes is an array. Transforming one variable into an array of its values, and an array into an object that takes into account the time factor, you can not only bring the debugging of the algorithm to a qualitatively higher level, but also change the idea of ​​programming.




All Articles