Jump to content

sasa

Staff Alumni
  • Posts

    2,804
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by sasa

  1. <?php $strg = "test.example.com"; echo $trimed = substr($strg, strpos($strg,'.')+1); ?>
  2. i try this code <?php function bm_extract_string($start, $end, $original) { $original1 = stripos($original, $start); $trimmed = stripos($original, $end); return substr($original, $original1+strlen($start), $trimmed-$original1-strlen($start)); } //$content = $r['content']; $content = "bla bla bla src='picture.bmp' bla bla"; $pic_string = bm_extract_string("src='","' ",$content); echo '<img src="'.$pic_string.'" />'; ?> and it outputs <img src="picture.bmp" />
  3. <?php $test = array('b'=> 1, 'a' => 2,'KEY NAME' => 3, 'sasa' => 123); $out = array_slice($test, array_search('KEY NAME',array_keys($test)),1); print_r($out); array_p ?>
  4. <?php for($i = 0; $i < 10000; $i++){ $formattedi = str_split(str_pad($i,4,'0',STR_PAD_LEFT)); $count = array_count_values($formattedi); $min = min($count); $max = max($count); if ($max == 2 and $min == 2) $out[] = implode('', $formattedi); } echo '<pre>', print_r($out), '</pre>'; ?>
  5. ups <?php function bm_extract_string($start, $end, $original) { $original1 = stripos($original, $start); $trimmed = stripos($original, $end); return substr($original, $original1+strlen($start), $trimmed-$original1-strlen($start)); } $content = $r['content']; $pic_string = bm_extract_string("src='","' ",$content); echo '<img src="'.$pic_string.'" />'; ?>
  6. try <?php function bm_extract_string($start, $end, $original) { $original1 = stristr($original, $start); $trimmed = stristr($original, $end); return substr($original, $origil1+strlen($start), $trimmed-$original1-strlen($start)); } $content = $r['content']; $pic_string = bm_extract_string("src='","' ",$content); echo '<img src="'.$pic_string.'" />'; ?>
  7. try <?php for($i = 0; $i < 10000; $i++){ $formattedi = str_split(str_pad($i,4,'0',STR_PAD_LEFT)); $count = array_count_values($formattedi); $min = min($count); $max = max($count); if($max == 1) $group = 'all different numbers'; if($max == 2 and $min == 2) $group = 'same numbers in pair'; if ($max == 3) $group = '3 same numbers'; if ($max == 2 and $min ==1) $group = '2 same numbers only'; if($max == 4) $group = '4 same numbers'; $out[$group][] = implode('', $formattedi); } echo '<pre>', print_r($out), '</pre>'; ?>
  8. insert $pagenum = $_GET['pagenum']; near the begin of script
  9. in your database type of country field is varchar(50) change it to varchar(100)
  10. change if (isset($_REQUEST['country'])) $strCountry = addslashes($_REQUEST['country']); else $strCountry = NULL; to if (isset($_REQUEST['country'])) $strCountry = addslashes(implode(',',$_REQUEST['country'])); else $strCountry = NULL; in files: inc_savestore.php and inc_updatestore.php
  11. error is in part where you insert value in database if you want insert array in db you must inplode it first
  12. try <?php for ($i = 1; $i < 1000; $i++){ $a = str_pad($i,3,'0',STR_PAD_LEFT); if (count(array_unique(str_split($a)))==3) echo $a, "<br />\n"; } ?>
  13. print(" <td class=\"viewtext\">".(isset($row['country']) ? implode(', ', $row['country']) : '')."</td>\n");
  14. or <?php $itemStr = '[Trees][300][boxes][4000][Gizmos][3]'; preg_match_all('/\[([^]]+)\]\[([^]]+)\]/',$itemStr,$out); print_r($out[1]); print_r($out[2]); ?>
  15. change print(" <td class=\"viewtext\">{$row['country']}</td>\n"); to print(" <td class=\"viewtext\">".implode(', ', $row['country'])."</td>\n");
  16. first write to database and after thet show data move this part to begin cho '<p>' . $sic_code_list . '</p>'; if (isset($_POST['submitted2'])) { // Initialize an error array. $errors = array(); $employer = $_GET['id']; if (empty($_POST['add_note'])) { $errors[] = 'You forgot to enter a new note.'; } else { $notes = mysqli_real_escape_string($dbc, trim($_POST['add_note'])); } $notes = "INSERT INTO emp_notes (id, employer, notes, entryDate) VALUES (NULL, '$employer', '$notes', CURRENT_TIMESTAMP) "; $run_notes = mysqli_query($dbc, $notes); }//end of main if statement
  17. <?php $counter = 0; while (your statement here) { if ($counter % 4 == 0){ echo "<div>\n"; } $counter++; //echo "\t$counter\n"; echo "your data"; if ($counter % 4 == 0){ echo "</div>\n"; } } if ($counter % 4 != 0){ echo "</div>\n"; } ?>
  18. trim elements of $game array before use array_intersedt foreach($game as $key => $value) $game[$key] = trim($value);
  19. <?php $counter = 0; while ($counter<11) { if ($counter % 4 == 0){ echo "<div>\n"; } $counter++; echo "\t$counter\n"; if ($counter % 4 == 0){ echo "</div\n"; } } if ($counter % 4 != 0){ echo "</div\n"; } ?>
  20. try to declare $news as array before use it ($news=array()
  21. try <?php //$myarray=array(array(1,2,3),2,array('sasa','red'), 3); echo "before writing to file<br />\n"; echo "<pre>"; echo print_r($myarray); echo "</pre>\n"; $fp = fopen('textfile.txt', 'w'); fwrite($fp, serialize($myarray)); fclose($fp); echo '<hr />'; $newarray = unserialize(file_get_contents('textfile.txt')); echo "after readin from file<br />\n"; echo "<pre>", print_r($newarray), "</pre>\n"; ?>
  22. $sql = "SELECT * FROM items WHERE `Item ID`= '".$_GET['id']."'";
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.