Jump to content

sasa

Staff Alumni
  • Posts

    2,804
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by sasa

  1. try if (($data=file("phone.csv", FILE_IGNORE_NEW_LINES))!== FALSE) { //while (($data=fgetcsv($open))!==FALSE) { foreach ($data as $key =>$numbr){ /// working code logic echo $key."<br>"; } }
  2. or <?php $string = "this, that;some.word;second"; $separators = array(":", ";", ",", "-", '\.');//must escape dot $result = preg_split('/('.implode('|',$separators).')\s*/',$string); print_r($result); ?>
  3. you need functions array_intersect() and array_diff() for this job
  4. try to explicite convert value to float type change line $tltsave = $invoiceline->total to $tltsave = (float)$invoiceline->total
  5. try <?php $a='sasa + sasa'; echo '<a href="?data='. urlencode($a).'">click me</a>'."<br />\n"; if (isset ($_GET)) echo $_GET['data']; ?> script just generate link with + and space, and echo result
  6. use urlencode() function on variable before put it in link and urldecode() on $_GET variable
  7. sasa

    Wrong regex ?

    are you sure about spaces try to use this pattern '~<a\s+href="solre.php?[^"]"\s*class=\'nav\'\s*>~'
  8. the variable $thing isn't set before you use it in query
  9. you can binary tree put in array in this way 1. root node put on index 1 in array 2. lchild of node with index n put in array element with indeks 2*n 3. rchild of node with index n put in array element with indeks 2*n+1 parent element of element with index n is in position (int)(n/2) level of element with index n is log(n, 2) (root element is level 0) on n-th level is elements with index from pow(2, n) to pow(2, n+1)-1 here is code for put tree in array <?php function tree_gather($node) //Function to calculate count { $tree = array(1 => $node); b_tree($node, 1, &$tree); return $tree; } function b_tree($node, $index, &$tree){ $sql = "SELECT lchild,rchild FROM tree WHERE parent = '$node'"; $execsql = mysql_query($sql); if($array = mysql_fetch_array($execsql)){ if(!empty($array['lchild'])){ $tree[$index * 2] = $array['lchild']; b_tree($array['lchild'], $index * 2, &$tree); } if(!empty($array['rchild'])){ $tree[$index * 2 + 1] = $array['rchild']; b_tree($array['rchild'], $index * 2 + 1, &$tree); } } } ?> the code is not tested
  10. change $laprov=$_POST["$provincias"]; to $laprov=$_POST["provincias"];
  11. change while($i <= $cuenta){ to while($i < $cuenta){ and some in 2n while loop
  12. <?php $array=array('word1', 'word2', 'word3'); $string="This is a sentence containing word2"; if(preg_match('/\b'. implode('\b|\b', $array).'\b/i', $string)) echo 'yes'; else echo 'no'; ?>
  13. you can use "... ORDER BY RAND($seed) ..." where $seed is random number generated for pagination see http://dev.mysql.com/doc/refman/5.0/en/mathematical-functions.html#function_rand
  14. $formula = $production_per_hour / 3600 * $difference + $current_number;
  15. try <?php $test = 'I am 13 as of today, what an unlucky number. "B1D3AY"'; function remove_numbers($a){ return preg_replace('/\d/','', $a[0]); } echo preg_replace_callback('/"[^"]+"/','remove_numbers',$test); ?>
  16. or just $temp = $_SESSION['Num_Part']; //$count = 0; //while ($count <= $temp){ $temp3=$_POST['Participant_P']; $temp5=$_POST['Result_P']; // $count++; //}
  17. try <?php $test = '<td> <b><font size="+2" color="#FF0000">Neighboorhood:</font> <font size="+2" color="#0000FF">Greenacre</font></b> </td> '; $out = preg_replace('/(Neighboorhood:.*?<font.*?)>/s', '\1 what you want to insert>', $test); echo $out; ?>
  18. $bio = preg_replace('#[^A-Za-z 0-9\']#i', '', $_POST['bio']);
  19. UPDATE points SET members_point=IF(members_point+1000 > 5000, 5000, members_point+1000).......
  20. look some pagination tutorials like http://www.phpfreaks.com/tutorial/basic-pagination
  21. try to do all job witk SQL <?php $r2 = mysql_query("SELECT MAX(progrm_id) AS level FROM user_program WHERE ID='".$usrid."' AND user_status='Active'"); $buffer_r2 = mysql_fetch_assoc($r2); $level_id = $buffer_r2['level']; $levels = array(1 => "Professional", "Gold", "Diamond", "Platinum", "Elite"); $level_name = $levels[$level_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.