Rookie’s PHP Notes (1,2)

Rookie PHP notes for about half an hour on July 15th General impression: PHP’s syntax turns out to be very similar to C language. I have long heard about PHP plus MySQL, but today I learned that PHP and MySQL are not a fixed combination. In fact, they can also be connected to databases such as Oracle, but MySQL is more common and easier to use. (1) Configure the Apache server: I have always heard that Apache and PHP should be used together, but now I know that Apache can also be used with ASP and JSP. In any case, in order to learn PHP, you must first go to Apache.org and download the Apache installation package. Of course, it is the version that can be installed directly. Later, you can learn the version that needs to be compiled by yourself. As a result, it conflicted with the original IIS during the installation process. Because port 80 was occupied, I had to temporarily uninstall IIS. Everything went smoothly after that. When I entered http://localhost/ in the browser, a large “It works!” appeared on the page. Indicates successful installation! Haha, now you can simply modify the homepage. Find the default access…

PHP array, how does $a={0,1,2,3} become $a={1,2,3,4]

PHP array, how does $a = {0,1,2,3} become $a = {1,2,3,4]. It is the dimension of the multi-dimensional array, and then adds 1 to the dimension and outputs it as the sequence number of the table, 1, 2, 3, 4 Reply to the discussion (solution) $a = array(0, 1, 2, 3);$b = range(1, count($a ));$c = array_combine($b, $a);print_r($c); Array ( [1] => 0 [2] => 1 [3] => 2 [4] => 3 ) $arr = array(0,1,2,3);$temp = array();foreach($arr as $k=>$v){ $k++; $temp[] = $k; }print_r($temp); The moderator’s is more beautiful! The moderator’s idea is beautiful, here is another idea.

Convert an array(255,11,22,2,0.) into image output in php-php tutorial

Obtaining a binary array of images from a third-party interface results in something similar to the following: $img_data = array(255,11,2,0,112,4,. ..); Could you please tell me how to convert the above array into image output? Reply to discussion (solution) Is this data abnormal If this is image data, then echo join(”, array_map(‘chr’, $img_data)); If this is image data, then echo join(”, array_map(‘chr’, $img_data)); #2 Correct answer, points will be posted soon; But I haven’t been exposed to PHP for a long time, so I don’t quite understand the principles. @xuzuning Bamboo Neng Can you explain it in general? The above data is equivalent to: 255 11 22 … .. I directly set the header to output it as a picture. array_map allows each element of the array to execute the specified function array_map(‘chr’, $img_data) is to allow each value of $img_data to execute the chr function. Convert values ​​to characters The join function joins arrays into strings

How to implement php to arrange in the order of 1, 2, 3 or 4, 5, solve

How to arrange php in the order of 1, 2, 3 or 4, 5? The solution is if there is a string of numbers 1, 2, 3, 7, 8, how can 123 be divided into a group, let’s say 7, 8 Assign to another group, that is, separate 1, 2, 3 and 7.8——Solution Idea————– ——– $s = ‘1, 2, 3, 7, 8’;$ar = explode(‘ ,’, $s);$arr = array();foreach($ar as $v){ $c = count($arr); if( $v == 1 ——Solution Idea———————- ($v != end($arr[$c-1]) +1)){ $arr[][] = $v; }else{ $arr[$c-1][] = $v; } }print_r($arr); Array( [0] => Array ( [0] => 1 [1] => 2 [2] => 3 ) [1] => Array ( [0] => 7 [1] => 8 ) )——Solution Idea———————- <?php $s = ‘1, 2, 3, 7, 8’; $ar = explode(‘,’, $ s); $arr = array(); foreach($ar as $v){ $c = count($arr); if($v == 1 ——Solution Idea———————- ($v != end($arr[$c-1]) +1)){ $arr[][] = $v; }else{ $arr[$ c-1][] = $v; } } $One= implode(‘,’,$arr[0]); $two = implode(‘,’,$arr[1]); echo “First winning streak:”.$one; echo “”; echo “Second winning streak:”.$two;?> Run results: First winning streak :1,2,3Second winning streak: 7,8

How does php realize the order of 1, 2, 3 or 4, 5, and solve

That is, if there is a string of numbers 1, 2, 3, 7, 8, how can we divide 123 into one group, let 7, 8 be divided into another group, that is, separate 1, 2, 3 and 7.8 4 solutions #1 What is the rule for grouping, 3 in the first group and 2 in the second? #2 Quoting the reply of jordan102 on the 1st floor: What is the rule for grouping, 3 in the first group and 2 in the second? This is not limited, it is just an example. It is a quiz winning streak record. Arrange it. If you guess three times in a row, record the id of these three times. day id #3 $s = ‘1, 2, 3, 7, 8’; $ar = explode(‘,’, $s); $arr = array(); foreach($ar as $v){ $c = count($arr); if($v == 1 || ($v != end($arr[$c-1]) +1)){ $arr[][] = $v; }else{ $arr[$c-1][] = $v; } } print_r($arr); Array ( [0] => Array ( [0] => 1 [1] => 2 [2] => 3 ) [1] => Array ( [0] => 7 [1] => 8 ) ) #4 <?php $s = ‘1, 2, 3, 7, 8’; $ar = explode(‘,’, $s); $arr =…

How does the php array elegantly convert 1,2,4,5,6,7,9,11 into strings like ‘1,2,47,9,11’?

As the title There is a php array 1234 [1,2,4,5, 6,7,9,11] [7,11,16,17,18,33,102,103,555] Elegant conversion to 12 ‘1,2,4-7,9, 11’ ‘7,11,16-18,33,102-103,555’ like this What about strings? Thank you for your answer.

A free administrative approval process component that I have been trying to improve for many years [2002 PHP  ,2008.NET,2

The free administrative approval process component that I have been trying to improve for many years [PHP in 2002, .NET in 2008, 2

php tutorial|php manual For many years, has been, perfected, free, administrative approval, process, component, 2002 Year, P php tutorial-php manual website source code uploaded and installed, the company computer vscode was uninstalled, ubuntu installed mondo, the tomcat window could not be closed, all kinds of crawlers were collected, php obtained global variables, how to achieve foreign trade promotion seo results, and the website realized multiple templates Switch, Taobao template website lzw There is almost no company, everything is decided by one person, and everyone needs to negotiate and coordinate to finally take effect. They all need to go through a process, which is why management software needs a process approval component. . Around 2002, in the company’s portal system EIP, an administrative approval process component was required. At that time, the database was implemented with PHP and the source code of the MySQL ball game trading platform was used. Vscode was incorrectly closed with an underscore and an error was reported. ISO and tomcat were installed under ubuntu Back root directory, ant wealth crawler, php5 mongodb, Xi’an 360seo optimization lzw supermarket purchase, sales and storage javaweb source code, ubuntu live website, start tomcat and print logs, scrapy crawler practice, what…

PHP A group of monkeys are arranged in a circle, numbered sequentially according to 1, 2, …, n.

1. A group of monkeys line up in a circle , according to 1,2,…,n numbered in turn. Then start counting from the 1st , count to the mth one, kick it out of the circle , start counting from behind it, count to the mth one, and kick it Go out…,go on and on, Until there is only one monkey left at the end,that monkey is called the king. Programming is required to simulate this process , input m, n, and output the number of the last king. function fn($n ,$m) { $arr = range(1,$n); $i = 0 ; //Set the array pointer while(count($arr)>1) {     //traverse the array , determine whether the current monkey is the serial number , if yes, exit , otherwise put To the end of the array if(($i+1) % $m ==0) { unset($arr[$i]);       } else { //array_push() function adds one or more elements to the end of the array of the first parameter ( onto the stack), and then returns the length of the new array. Array_push($arr, $arr[$i]); //The non-out monkeys of this round put the tail of the array unset($arr[$i]); //Delete The array_push function just copies the elements One moved…

underscore knowledge points_error: partition(s) 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,_cily_undefined’s blog

1. Installation Node. js –> npm install underscore Meteor.js –> meteor add underscore Require.js –> require([“underscore”], … Bower bower –> install underscore Component –> component install jashkenas/underscore Second, aggregate function (array or object) 1, each Syntax: _.each(list, iteratee, [context]) Description: Traverse all elements in the list, and call the iteratee function with each element as a parameter in order. If the context parameter is passed, bind iteratee to the context object. Each call to iteratee passes three parameters: (element, index, list). If list is a JavaScript object, the arguments to iteratee are (value, key, list)). Return a list to facilitate chain calls. Example: _.each([1, 2, 3], alert); => alerts each number in turn… _.each({one: 1, two: 2, three: 3}, alert); => alerts each number value in turn… 2, map Syntax: _.map(list, iteratee, [context]) Description: Generate a corresponding array by calling the conversion function (iteratee iterator) for each element in the list. iteratee passes three parameters: value, then the iteration index (or key Fool’s Wharf note: if the list is a JavaScript object, this parameter is the key), and the last one is a reference to the entire list. Example: _.map([1, 2, 3], function(num){ return num * 3; }); => [3,…

count(1), count(*), orderby1,2,3,4 difference

count(1), count(*), orderby1,2,3,4 difference

Count(1), count(*), order by 1,2,3,4 difference the 1 make NULL data; the the 2 directly use the column name to COUNT to see the result the the 3 Use 1 2 3 4 5 * to COUNT to look at the results and find that they are all the same data and are equal to all functions. www.2cto.com the 4 ORDER BY 1 does use the first column to sort the the 5 ORDER BY 2 See if the result is correct the the result: the count(1)=count(2)=count(3)=count(*); the count(provcode)count(areacode)count(statedate)count(*); the order by 1order by 2oreder by 3; the order by 1=order by provcode the Additional results: the the the Author ZengMuAnSha

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: [email protected]

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索