sasa
Staff Alumni-
Posts
2,804 -
Joined
-
Last visited
-
Days Won
1
Everything posted by sasa
-
Copy Machine-Esque Collation of an Array - Not Your Mother's Collation
sasa replied to cobraroll98's topic in PHP Coding Help
try <?php function my_order($a){ if (!is_array($a)) return false; $out = array(); while (count($a)){ $tmp = array_unique($a); sort($tmp); $out = array_merge($out, $tmp); foreach ($tmp as $val){ unset($a[array_search($val,$a)]); } } return $out; } $start = '1,2,3,4,5,5,4,3,2,1,1,2,3,4,5,3,2'; $start = explode(',',$start); echo implode(',', my_order($start)); ?> -
i changed my permutation function but i don't change its name sorry
-
maybe not try <?php $a = '001'; switch ($a): case '1': echo 'ok'; break; default: echo 'no'; break; endswitch; ?>
-
'0000E00' means 0000*10^0 = 0 (float) change line case "00000E00": to case $profile==="00000E00":
-
try <?php $self=$_SERVER['PHP_SELF']; $str.= "<table align='center' border='1'><tr><td align='center'><b>Name</b></t d><td align='center'><b>Email Address</b></td><td align='center'><b>Add Contact</b></td>"; echo"<form method='POST' action='$self?cmd=add_contacts'>"; $contacts = array("john"=>"john@lucky.co.uk", "sam"=>"sam@lucky.com"); foreach($contacts as $name => $email){ $str.="<tr><td style='Font-Family:verdana;Font-Size:14'>".$name."</td> <td style='Font-Family:verdana;Font-Size:14'>".$email."</td><td align='center'> <select name='add[]'><option value='no' selected='selected'>No<option value='yes'>Yes</option></select> <input type='hidden' name='contacts_name[]' value='".$name."'> <input type='hidden' name='contacts_email[]' value='".$email."'> </td></tr>"; } $str.= "</table><br><br><input type='submit' name='add_contact' value='Add my contacts!'> <br><br>"; echo"<table border='0' width='800px' align='left'> <tr> <td align='center'> You have total <font color='blue'>$totalRecords</font> contacts <br><br> $str </td></tr> </table>"; if($_POST['add_contact']){ $add=$_POST['add']; $contacts_name=$_POST['contacts_name']; $contacts_email=$_POST['contacts_email']; foreach($add as $key => $a){ if ($a == 'yes') echo " <br><br> Name: ",$contacts_name[$key]," Email ",$contacts_email[$key]," Add $a<br><br>"; } } ?>
-
change $title .= '<div><input type="checkbox" name="checkboxes[' . $names . ']" class="checkbox" id="' . $names . '" ' . $chk . ' value="1" /> <label for="checkboxes[' . $names . ']">' . ucwords(str_replace($numbers, '', $names)) . '</label></div>' to $title .= '<div><input type="hidden" name="checkboxes[' . $names . ']" value="0"><input type="checkbox" name="checkboxes[' . $names . ']" class="checkbox" id="' . $names . '" ' . $chk . ' value="1" /> <label for="checkboxes[' . $names . ']">' . ucwords(str_replace($numbers, '', $names)) . '</label></div>' and tray to print_r($_POST['checkboxes']);
-
try <?php function my_permut($a, $num, $start = 0){ if(!is_array($a)) return false; if (count($a) == $num) return array($a); if ($num == 1){ $out = array(); for ($i = $start; $i < count($a); $i++) $out[]=array($a[$i]); return $out; } $a = array_values($a); $out = array(); for ($i = $start; $i <= count($a) - $num; $i++){ $d = my_permut($a, $num-1, $i+1); foreach ($d as $e){ array_unshift($e,$a[$i]); $out[] = $e; } } return $out; } $x = my_permut(array(1,2,3,4,5),3); print_r($x); ?>
-
try <?php function hformat($number) { $suffix = array('', ' K', ' M', ' B',' T', ' Q'); $max = count($suffix) - 1; while ($number >= 1000 and $i < $max){ $number /= 1000; $i++; } $number = round($number, 2); return $number . $suffix[$i]; } echo hformat(1234567891234567); ?>
-
remove ' from query
-
try echo $dom->getElementById('menubox')->textContent;
-
try <?php $data_name = '`'.implode('`,`',array_flip($_POST['checkboxes'])).'`'; $data_value = "'".implode("','",$_POST['checkboxes'])."'"; $qry = mysql_query("INSERT INTO fake ($data_name) VALUES ($data_value)") or die(mysql_error()); ?>
-
try <?php $a = '<img class="alignnone size-medium wp-image-71" title="5bwallcoo_com5d_photobook_horikitam1" src="http://localhost/wordpress/wp-content/uploads/2008/09/5bwallcoo_com5d_photobook_horikitam1-300x225.jpg" alt="" width="300" height="225" /><img class="alignnone size-medium wp-image-73" title="normal_maki-horikita-0098-92784" src="http://localhost/wordpress/wp-content/uploads/2008/09/normal_maki-horikita-0098-92784-300x225.jpg" alt="" width="300" height="225" /> [caption id="attachment_72" align="alignnone" width="265" caption="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"]<img class="size-medium wp-image-72" title="maki" src="http://localhost/wordpress/wp-content/uploads/2008/09/maki-265x300.jpg" alt="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz" width="265" height="300" /><img class="alignnone size-medium wp-image-70" title="4f04e9a0102900_full1" src="http://localhost/wordpress/wp-content/uploads/2008/09/4f04e9a0102900_full1-300x225.jpg" alt="" width="300" height="225" />'; preg_match_all('|<img [^>]*src="([^"]+)"|is',$a,$out); print_r($out[1]); ?>
-
try <?php $start_day = strtotime("1 October 2007"); $end_day = strtotime("25 May 2009"); $j = 0; $period = 0; for ($i=$start_day;$i<=$end_day;) { for($x=1;$x<=10;$x++) { echo date("d M Y",$i) . " => Army Day :" . $j . " => Period: " . $period . " => Period day :" . $x ."<br>\n"; $i+=86400; $j++; if ($i > $end_day) break; } $period++; } ?>
-
array_reverse();
-
but $split1[0] != $split1[1] which of this two elements want to remove from array
-
try for($i = 1; $i < 32; $i++){ for($value = 1; $value < 5;$value++){ echo "<input type="radio" name='$i' value=$value> $value "; } echo "<br />\n"; }
-
look http://hr.php.net/array_intersect
-
if you have $num="76561200929753726"; in variable $num is STRING and if you try to echo it echo is 76561200929753726 but when you try to do some aritmetic with this variable php convert it in number if you want to calculate with this long number you can setup your aritmetical functions
-
just use sort() function
-
Ttry $sReplaceHTML = preg_replace( '%<tr><td height="290" colspan="3"></td></tr><tr><td height="163" valign="top" colspan="3"></td></tr>%is','',$sStripDOC );[/code
-
can you print_r($rows); and post output
-
are you setup arabic collation for db too?
-
[SOLVED] Getting 2 table 'rows' beside each other
sasa replied to sirenia's topic in PHP Coding Help
try <?php ... // start table echo "<table border=\"0\" cellspacing=\"1\" cellspacing=\"2\" width=\"210\">"; while ($row=mysql_fetch_array($result2)) { $id=$row["id"]; $twelve=$row["twelve"]; $ten=$row["ten"]; $eight=$row["eight"]; $artist=$row["artist"]; $type=$row["type"]; $series=$row["series"]; $preview=$row["preview"]; if ($numcolsprinted == 0) print "<tr>\n"; echo "<td class=\"temp\"><img src=\"$preview\"><br> <b>ID:</b> $id<br> <b>Series:</b> $series<br> <b>Artist:</b> $artist<br> </td>\n"; $numcolsprinted++; if ($numcolsprinted == $numcols) { echo "</tr>\n"; $numcolsprinted = 0; } } if ($numcolsprinted > 0){ for (; $numcolsprinted <= $numcols; $numcolsprinted++) echo "<td> </td>\n"; echo "</tr>\n"; } echo "</table>\n"; ... ?>