sasa
Staff Alumni-
Posts
2,804 -
Joined
-
Last visited
-
Days Won
1
Everything posted by sasa
-
<?php $strg = "test.example.com"; echo $trimed = substr($strg, strpos($strg,'.')+1); ?>
-
implode $out
-
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" />
-
<?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 ?>
-
<?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>'; ?>
-
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.'" />'; ?>
-
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.'" />'; ?>
-
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>'; ?>
-
insert $pagenum = $_GET['pagenum']; near the begin of script
-
Probably Easy, Need help with Check Boxes in PHP Code
sasa replied to winuser2003's topic in PHP Coding Help
in your database type of country field is varchar(50) change it to varchar(100) -
Probably Easy, Need help with Check Boxes in PHP Code
sasa replied to winuser2003's topic in PHP Coding Help
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 -
Probably Easy, Need help with Check Boxes in PHP Code
sasa replied to winuser2003's topic in PHP Coding Help
error is in part where you insert value in database if you want insert array in db you must inplode it first -
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"; } ?>
-
Probably Easy, Need help with Check Boxes in PHP Code
sasa replied to winuser2003's topic in PHP Coding Help
print(" <td class=\"viewtext\">".(isset($row['country']) ? implode(', ', $row['country']) : '')."</td>\n"); -
or <?php $itemStr = '[Trees][300][boxes][4000][Gizmos][3]'; preg_match_all('/\[([^]]+)\]\[([^]]+)\]/',$itemStr,$out); print_r($out[1]); print_r($out[2]); ?>
-
Probably Easy, Need help with Check Boxes in PHP Code
sasa replied to winuser2003's topic in PHP Coding Help
change print(" <td class=\"viewtext\">{$row['country']}</td>\n"); to print(" <td class=\"viewtext\">".implode(', ', $row['country'])."</td>\n"); -
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
-
<?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"; } ?>
-
look preg_replace_callback() function
-
trim elements of $game array before use array_intersedt foreach($game as $key => $value) $game[$key] = trim($value);
-
<?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"; } ?>
-
[SOLVED] Class could not be converted to string
sasa replied to XpertWorlock's topic in PHP Coding Help
try to declare $news as array before use it ($news=array() -
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"; ?>
-
$sql = "SELECT * FROM items WHERE `Item ID`= '".$_GET['id']."'";