This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$list = array( | |
array('id'=>1,'name'=>'Fashion','parent_id'=>null), | |
array('id'=>2,'name'=>'Men','parent_id'=>1), | |
array('id'=>3,'name'=>'Women','parent_id'=>1), | |
array('id'=>4,'name'=>'Jacket Men','parent_id'=>2), | |
array('id'=>5,'name'=>'Jacket Women','parent_id'=>3), | |
array('id'=>6,'name'=>'Bag','parent_id'=>null), | |
array('id'=>7,'name'=>'Bag Men','parent_id'=>6), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$a = array( | |
'email' => 'test@test.com', | |
'desc' => 'Who know', | |
'button_link' => 'yest' | |
); | |
function qh_combine(&$item, $key){ | |
$item = "$key : $item"; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
echo "PHP Knapsack 1/0 problem \n"; | |
class Item | |
{ | |
private $_weight; | |
private $_value; | |
public function __construct($value, $weight) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$data = array(); | |
$data = array( | |
'channel' => 1, | |
'data' => array ( | |
array( | |
'identity' => array('email' => 'email'), | |
'events' => array( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
value = [[0 for x in xrange(0, W+1)] for x in xrange(0, n+1)] | |
keep = [[0 for x in xrange(0,W+1)] for x in xrange(0, n+1)] | |
for w in range(0, n): | |
value[0][w] = 0 | |
keep[0][w] = 0 | |
for i in xrange(1, n+1): | |
for w in xrange(0, W+1): | |
if((weight[i] <= w) and (v[i] + value[i-1][w-weight[i]] > value[i-1][w])): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$arr1 = array(0=>'0', 1=>'0', 2=>'0', 3=>'0', 4=>'0', 5=>'0', 6=>'0'); | |
$arr2 = array(0=>'2', 3=>'5', 5=>'8'); | |
$arr3 = array(); | |
foreach($arr1 as $k1 => $v1){ | |
foreach ($arr2 as $k2 => $v2) { | |
if($k1==$k2){ | |
$arr3[$k1] = $v2; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
#Equivalent to this PHP codes: | |
$gmt_timezone = new DateTimeZone('GMT'); | |
$obj_date = new DateTime(null,$gmt_timezone); | |
echo $obj_date->format('d/m/Y h:i:s'); | |
#OR | |
date_default_timezone_set("GMT"); | |
echo date('d/m/Y h:i:s', time()); | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$parrot = "Norwegian Blue"; | |
echo strlen($parrot); | |
echo strtolower($parrot); | |
echo strtoupper($parrot); | |
$pi = 3.14 | |
echo $pi; | |
if(is_string($pi)): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for num in 1..10 | |
puts num | |
end | |
for i in 1..50 | |
print i | |
end | |
i = 1 | |
while i <= 50 do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
puts "Please input original text:" | |
text = gets.chomp | |
puts "Please input redact:" | |
redact = gets.chomp | |
words = text.split(" ") | |
words.each do |word| | |
if word == redact | |
print "REDACTED " |
OlderNewer