Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
devwiki:php [2017/07/26 23:01]
ying [Python Task to PHP Task]
devwiki:php [2017/07/27 01:32] (current)
ying [Python Task to PHP Task]
Line 35: Line 35:
 $array = array('​lastname',​ '​email',​ '​phone'​);​ $array = array('​lastname',​ '​email',​ '​phone'​);​
 $comma_separated = implode(",",​ $array); $comma_separated = implode(",",​ $array);
- 
 echo $comma_separated;​ // lastname,​email,​phone echo $comma_separated;​ // lastname,​email,​phone
 </​code>​ </​code>​
 +  * show IP <code php>
 +echo $_SERVER["​REMOTE_ADDR"​]; ​
 +</​code>​
 +  * list related operation <code php>
 +// item in list
 +if (in_array("​Glenn",​ $people))
 +{
 +echo "Match found";​
 +}
  
 +// add items
 +$a=array("​red","​green"​);​
 +array_push($a,"​blue","​yellow"​);​
 +// sum items
 +array_sum($num_list)
 +
 +// iterate item like python enumerate
 +foreach (array_values($lst) as $i => $val) {
 +    echo "$i $val \n";
 +}
 +</​code>​
 ===== php syntax ===== ===== php syntax =====
 <code php> <code php>