Search Results

Search found 410 results on 17 pages for 'explode'.

Page 8/17 | < Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >

  • Detecting a url using preg_match? without http:// in the string

    - by Stefan
    Hey there, I was wondering how I could check a string broken into an array against a preg_match to see if it started with www. I already have one that check for http://www. $stringToArray = explode(" ",$_POST['text']); foreach($stringToArray as $key=>$val){ $urlvalid = isValidURL($val); if($urlvalid){ $_SESSION["messages"][] = "NO URLS ALLOWED!"; header("Location: http://www.domain.com/post/id/".$_POST['postID']); exit(); } } Thanks! Stefan

    Read the article

  • PHP - not returning a count number for filled array...

    - by Phil Jackson
    Morning, this is eating me alive so Im hoping it's not something stupid, lol. $arrg = array(); if( str_word_count( $str ) > 1 ) { $input_arr = explode(' ', $str); die(print_r($input_arr)); $count = count($input_arr); die($count); above is part of a function. when i run i get; > Array ( > [0] => luke > [1] => snowden > [2] => create > [3] => develop > [4] => web > [5] => applications > [6] => sites > [7] => alse > [8] => dab > [9] => hand > [10] => design > [11] => love > [12] => helping > [13] => business > [14] => thrive > [15] => latest > [16] => industry > [17] => developer > [18] => act > [19] => designs > [20] => php > [21] => mysql > [22] => jquery > [23] => ajax > [24] => xhtml > [25] => css > [26] => de > [27] => montfont > [28] => award > [29] => advanced > [30] => programming > [31] => taught > [32] => development > [33] => years > [34] => experience > [35] => topic > [36] => fully > [37] => qualified > [38] => electrician > [39] => city > [40] => amp > [41] => guilds > [42] => level ) Which im expecting; run this however and nothing is returned!?!?! $arrg = array(); if( str_word_count( $str ) > 1 ) { $input_arr = explode(' ', $str); //die(print_r($input_arr)); $count = count($input_arr); die($count); can anyone see anything that my eyes cant?? regards, Phil

    Read the article

  • Weird use of generics

    - by Karl Trumstedt
    After a bit of programming one of my classes used generics in a way I never seen before. I would like some opinions of this, if it's bad coding or not. abstract class Base<T> : where T : Base<T> { // omitted methods and properties. virtual void CopyTo(T instance) { /*code*/ } } class Derived : Base<Derived> { override void CopyTo(Derived instance) { base.CopyTo(instance); // copy remaining stuff here } } is this an OK use of generics or not? I'm mostly thinking about the constraint to "itself". I sometimes feel like generics can "explode" to other classes where I use the Base class.

    Read the article

  • php - feof error

    - by TwixxyKit
    The file that I'm trying to read is a pgp-encrypted file. This is part of the process to decrypt it and I'm actually attempting to read the contents into a string so that I can then decrypt it . I'm not sure if that's the core problem here or not, but I'm getting an error: Warning: feof(): supplied argument is not a valid stream resource Here's the file code: if($handle = opendir($dir)) { while( false !== ($file = readdir($handle))) { if($file != "." && $file != "..") { $fhandle = fopen($file, "r"); $encrypted = ''; $filename = explode('.',$file); while(!feof($fhandle)) { $encrypted .= fread($fhandle, filesize($file)); } fclose($fhandle); $decrypted = $filename[0].'.txt'; shell_exec("echo $passphrase | $gpg --passphrase-fd 0 -o $decrypted -d $encrypted"); } } }

    Read the article

  • Read tab delimited text file into MySQL table with PHP

    - by Simon S
    I am trying to read in a series of tab delimited text files into existing MySQL tables. The code I have is quite simple: $lines = file("import/file_to_import.txt"); foreach ($lines as $line_num => $line) { if($line_num > 1) { $arr = explode("\t", $line); $sql = sprintf("INSERT INTO my_table VALUES('%s', '%s', '%s', %s, %s);", trim((string)$arr[0]), trim((string)$arr[1]), trim((string)$arr[2]), trim((string)$arr[3]), trim((string)$arr[4])); mysql_query($sql, $database) or die(mysql_error()); } } But no matter what I do (hence the casting before each variable in the sprintf statement) I get the "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1" error. I echo out the code, paste it into a MySQL editor and it runs fine, it just won't execute from the PHP script. What am I doing wrong?? Si

    Read the article

  • best way to get new access_token using PHP sdk

    - by randy
    I am getting the error "An active access token must be used to query information about the current user". There seems to be tons of articles and ideas, but am very confused and it seems that things are changing as well. A lot say to use offline-access but that appears to be going away. I did find this article. Does anyone have an example using the PHP SDK? I tried doing something like the below but it does not seem to work; $FBuser is still zero: $token_url = "https://graph.facebook.com/oauth/access_token?" . "client_id=" . FB_APP_ID . "&client_secret=" . FB_APP_SECRET . "&grant_type=client_credentials"; list($name, $ACCESS_TOKEN) = explode("=", file_get_contents($token_url) ); $facebook->setAccessToken(ACCESS_TOKEN); $FBuser = $facebook->getUser();

    Read the article

  • Only variables can be passed by reference

    - by zaf
    I had the bright idea of using a custom error handler which led me down a rabbit hole. Following code gives (with and without custom error handler): Fatal error: Only variables can be passed by reference function foo(){ $b=array_pop(array("a","b","c")); return $b; } print_r(foo()); Following code gives (only with a custom error handler): (2048) Only variables should be passed by reference function foo(){ $a=explode( '/' , 'a/b/c'); $c=array_pop(array_slice($a,-2,1)); return $c; } print_r(foo()); The second one worries me since I have a lot of 'compact' code. So, I either ditch the bright idea of using a custom error handler (to improve my logging module) or expand all my code. Anyone with better ideas? Also, WTF?

    Read the article

  • page not show after issuing zf command

    - by Nazmin
    hello guys, just simple question, recently i have setup a web server to build project using zend framework, after setup and see those welcome page saying that you are creating websites powered by zendframework, then i try issuing command, $ zf create controller alert i get the message that saying that i've successfully create controller, view and so on, but when i try to navigate to the page by URL, ex: www.mywebapp.com/alert the page is broken, i've check those tuts but none of them showing this case. can some one define which step i've skip? update: (25/5/2010) so i've found that there is no problem, is just that i've not configured properly my route to my web apps, so i have to type URL like this: www.mywebapp.com/index.php/alert how am I going to change this? i mean i want to explode "index.php" out of URL.

    Read the article

  • Retain Count Question: Some Guidance, Please

    - by yar
    [I'm sure this is not odd at all, but I need just a bit of help] I have two retain properties @property (nonatomic, retain) NSArray *listContent; @property (nonatomic, retain) NSArray *filteredListContent; and in the viewDidLoad method I set the second equal to the first (so now the retainCount is two, I think): self.filteredListContent = self.listContent; and then on every search I do this self.filteredListContent = [listContent filteredArrayUsingPredicate:predicate]; I thought I should do a release right above this assignment -- since the property should cause an extra retain, right? -- but that causes the program to explode the second time I run the search method. The retain counts (without the extra release) are 2 the first time I come into the search method, and 1 each subsequent time (which is what I expected, unfortunately). Some guidance would help, thanks! Is it correct to not release?

    Read the article

  • All minimum spanning trees implementation

    - by russtbarnacle
    I've been looking for an implementation (I'm using networkx library.) that will find all the minimum spanning trees (MST) of an undirected weighted graph. I can only find implementations for Kruskal's Algorithm and Prim's Algorithm both of which will only return a single MST. I've seen papers that address this problem (such as http://fano.ics.uci.edu/cites/Publication/Epp-TR-95-50.html) but my head tends to explode someway through trying to think how to translate it to code. In fact i've not been able to find an implementation in any language!

    Read the article

  • url to http request object

    - by takeshin
    I need to convert string like this: $url = 'module/controller/action/param1/param1value/paramX/paramXvalue'; to url regarding current router (including translation and so on). Usually I generate the target urls using url view helper, but for this I need to specify all params, so I would need to manually explode the string. I tried to use request object, like this: $request = new Zend_Controller_Request_Http(); // some code here passing the $url Zend_Debug::dump($request->getControllerName()); // null instead of 'controllers' Zend_Debug::dump($request->getParams()); // null instead of array but this seems to be suspected. Do I need to dispatch this request? How to handle this case well?

    Read the article

  • A RecursiveParentChildIterator -- like the RecursiveDirectoryIterator

    - by Stephen J. Fuhry
    There are tons of examples of using the RecursiveIterator to flatten a tree structure.. but what about using it to explode a tree structure? Is there an elegant way to use this, or some other SPL library to recursively build a tree (read: turn a flat array into array of arbitrary depth) given a table like this: SELECT id, parent_id, name FROM my_tree EDIT: You know how you can do this with Directories? $it = new RecursiveDirectoryIterator("/var/www/images"); foreach(new RecursiveIteratorIterator($it) as $file) { echo $file . PHP_EOL; } .. What if you could do something like this: $it = new RecursiveParentChildIterator($result_array); foreach(new RecursiveIteratorIterator($it) as $group) { echo $group->name . PHP_EOL; // this would contain all of the children of this group, recursively $children = $group->getChildren(); } :END EDIT

    Read the article

  • Database design: Using hundred of fields for little values

    - by user964260
    I'm planning to develop a PHP Web App, it will mainly be used by registered users(sessions) While thinking about the DB design, I was contemplating that in order to give the best user experience possible there would be lots of options for the user to activate, deactivate, specify, etc. For example: - Options for each layout elements, dialog boxes, dashboard, grid, etc. - color, size, stay visible, invisible, don't ask again, show everytime, advanced mode, simple mode, etc. This would get like 100s of fields ranging from simple Yes/No or 1 to N values..., for each user. So, is it having a field for each of these options the way to go? or how do those CRMs or CMS or other Web Apps do it to store lots of 1-2 char long values? Do they group them on Text fields separated by a special char and then "explode" them as an array for runtime usage? thank you

    Read the article

  • Paypal development. encrypt transactions. php p12

    - by ninchen
    when i take a look at the paypal documentation, they say "Note that the PayPal SDK for PHP does not require SSL encryption". https://developer.paypal.com/docs/classic/api/apiCredentials/#encrypting-your-certificate Is the statement of this phrase, that i don't have to create a p12 certificate when working with php, but use the public_key.pem and paypal_public_key.pem? If yes: Is it secure enough to create the encrypted form input elements without p12 certificate? If no: What do they mean? :-) Before this question came up, i've tested this little programm. http://www.softarea51.com/blog/how-to-integrate-your-custom-shopping-cart-with-paypal-website-payments-standard-using-php/ There is a config file paypal-wps-config.inc.php where i can define the paths to my certificates. // tryed to use // 'paypal_cert.p12 '; $config['private_key_path'] = '/home/folder/.cert/pp/prvkey.pem'; // must match the one you set when you created the private key $config['private_key_password'] = ''; //'my_password'; When i try to use the p12 certificate, openssl_error_string() returns "Could not sign data: error:0906D06C:PEM routines:PEM_read_bio:no start line openssl_pkcs7_sign When i instead use the prvkey.pem without password all works fine. Here is the function, which signs and encrypt the data. function signAndEncrypt($dataStr_, $ewpCertPath_, $ewpPrivateKeyPath_, $ewpPrivateKeyPwd_, $paypalCertPath_) { $dataStrFile = realpath(tempnam('/tmp', 'pp_')); $fd = fopen($dataStrFile, 'w'); if(!$fd) { $error = "Could not open temporary file $dataStrFile."; return array("status" => false, "error_msg" => $error, "error_no" => 0); } fwrite($fd, $dataStr_); fclose($fd); $signedDataFile = realpath(tempnam('/tmp', 'pp_')); **// here the error came from** if(!@openssl_pkcs7_sign( $dataStrFile, $signedDataFile, "file://$ewpCertPath_", array("file://$ewpPrivateKeyPath_", $ewpPrivateKeyPwd_), array(), PKCS7_BINARY)) { unlink($dataStrFile); unlink($signedDataFile); $error = "Could not sign data: ".openssl_error_string(); return array("status" => false, "error_msg" => $error, "error_no" => 0); } unlink($dataStrFile); $signedData = file_get_contents($signedDataFile); $signedDataArray = explode("\n\n", $signedData); $signedData = $signedDataArray[1]; $signedData = base64_decode($signedData); unlink($signedDataFile); $decodedSignedDataFile = realpath(tempnam('/tmp', 'pp_')); $fd = fopen($decodedSignedDataFile, 'w'); if(!$fd) { $error = "Could not open temporary file $decodedSignedDataFile."; return array("status" => false, "error_msg" => $error, "error_no" => 0); } fwrite($fd, $signedData); fclose($fd); $encryptedDataFile = realpath(tempnam('/tmp', 'pp_')); if(!@openssl_pkcs7_encrypt( $decodedSignedDataFile, $encryptedDataFile, file_get_contents($paypalCertPath_), array(), PKCS7_BINARY)) { unlink($decodedSignedDataFile); unlink($encryptedDataFile); $error = "Could not encrypt data: ".openssl_error_string(); return array("status" => false, "error_msg" => $error, "error_no" => 0); } unlink($decodedSignedDataFile); $encryptedData = file_get_contents($encryptedDataFile); if(!$encryptedData) { $error = "Encryption and signature of data failed."; return array("status" => false, "error_msg" => $error, "error_no" => 0); } unlink($encryptedDataFile); $encryptedDataArray = explode("\n\n", $encryptedData); $encryptedData = trim(str_replace("\n", '', $encryptedDataArray[1])); return array("status" => true, "encryptedData" => $encryptedData); } // signAndEncrypt } // PPCrypto The main questions: 1. Is it possible to use p12 cert with php, or is it secure enough to work without it? 2. Why i become an error when using openssl_pkcs7_sign Please help. Greetings ninchen

    Read the article

  • draw line with php using coordinates from txt file

    - by netmajor
    I have file A2.txt with coordinate x1,y1,x2,y2 in every line like below : 204 13 225 59 225 59 226 84 226 84 219 111 219 111 244 192 244 192 236 209 236 209 254 223 254 223 276 258 276 258 237 337 in my php file i have that code. This code should take every line and draw line with coordinate from line. But something was wrong cause nothing was draw :/: <?php $plik = fopen("A2.txt", 'r') or die("blad otarcia"); while(!feof($plik)) { $l = fgets($plik,20); $k = explode(' ',$l); imageline ( $mapa , $k[0] , $k[1] , $k[2] , $k[3] , $kolor ); } imagejpeg($mapa); imagedestroy($mapa); fclose($plik) ; ?> If I use imagejpeg and imagedestroy in while its only first line draw. What to do to draw every line ?? Please help :)

    Read the article

  • delphi "Invalid use of keyword" in TQuery

    - by Baldric
    I'm trying to populate a TDBGrid with the results of the following TQuery against the file Journal.db: select * from Journal where Journal.where = "RainPump" I've tried both Journal."Where" and Journal.[Where] to no avail. I've also tried: select Journal.[Where] as "Location" - with the same result. Journal.db is a file created by a third party and I am unable to change the field names. The problem is that the field I'm interested in is called 'where' and understandably causes the above error. How do I reference this field without causing the BDE (presumably) to explode?

    Read the article

  • PHP: How can I eliminate quotes around output from CSV file?

    - by brian johnson
    This code: <?php $curl=curl_init(); curl_setopt ($curl,CURLOPT_URL,"http://download.finance.yahoo.com/d/quotes.csv?s=XIN&f=l1c1p2rj1y&e=.csv"); curl_setopt ($curl,CURLOPT_HEADER,0); ob_start(); curl_exec ($curl); curl_close ($curl); $data=ob_get_clean(); $data = explode(",",$data); foreach ($data as $results) echo "<td>$results</td>"; ?> yields these results in my browser: 2.80 +0.02 "+0.72%" 1.85 204.2M 1.44 How can I have this PHP code above eliminate the quotations around the "+0.72%" so the end result is just: 0.72% ?

    Read the article

  • failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request

    - by muralikalpana
    I am accessing images from another website. I am getting "failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request " error when copying 'some(not all)' images. here is my code. $img=$_GET['img']; //another website url $file=$img; function getFileextension($file) { return end(explode(".", $file)); } $fileext=getFileextension($file); if($fileext=='jpg' || $fileext=='gif' || $fileext=='jpeg' || $fileext=='png' || $fileext=='x-png' || $fileext=='pjpeg'){ if($img!=''){ $rand_variable1=rand(10000,100000); $node_online_name1=$rand_variable1."image.".$fileext; $s=copy($img,"images/".$node_online_name1); }

    Read the article

  • recaptcha image and curl + php

    - by user253530
    $page = $curl->post($baseUrl.'/submit.php', array('url'=>$address,'phase'=>'1','randkey'=>$randKey[0],'id'=>'c_1')); $exp = explode('recaptcha_image',$page); The id recaptcha_image is not found although if i echo $page; the webpage will be displayed and surprisingly even the recpatcha div (with the image itself). Curl shouldn't load the image for recaptcha but somehow it does though when i try to find the div, it is not there. Is there a way to capture the url of the recaptcha image?

    Read the article

  • Unneded number combination after replacing a number in a string.

    - by ne5tebiu
    I get an unneeded number combination. 3, 4, 5, 6, 7, 8, 901234567890123456789, 30 Should be: 3, 4, 5, 6, 7, 8, 9, 10, 11, 12... (till) 30 Why that happens? The code: <? ob_start(); $id=$_GET['id']; if (!empty($id)){ $id=str_replace('a9_','', $id); $value=$_COOKIE['NaudingasURL']; $exp = explode(", ", $value); if(in_array($id, $exp)){ $value2=str_replace(', '.$id,"", ', '.$value); $value2=substr($value2, 2, strlen($value2)); echo'r'; } else{ $value2=$value.', '.$id; echo'a'; } setcookie("NaudingasURL", $value2); } ob_end_flush(); ?> I'm calling it with Jquery ajax, but I don't thinks that's the problem.

    Read the article

  • fread how to Count total from Counter text

    - by snikolov
    hey i have a counter text here and i need to know how to calculate the total this is my information $filename = "data.txt"; $handle = fopen($filename, "r"); $contents = fread($handle, filesize($filename)); $expode = explode("\n",$contents); /** output 1024 1024 1024 1024 1024 1024 1024 1024 1024 1024 1024 1024 1024 */ I i need to calculate the total by exploding "\n" so i will output 12288 need to understand how to do this i have done this foreach ($expode as $v) { $total = $total + $v; echo $total; } i did not get good results with this

    Read the article

  • PHP/mySQL - using result from 'CONCAT' and 'AS' in 'LIKE' clause

    - by Phil Jackson
    Hi I have the following code; if( ! empty( $post['search-bar'] ) ) { $search_data = preg_replace("#\s\s#is", '', preg_replace("#[^\w\d\s+]#is", '', $post['search-bar'] ) ); $data_array = explode( " ", $search_data ); $data_array = "'%" . implode( "%' OR '%", $data_array ) . "%'"; $query = "SELECT CONCAT( PROFILE_PROFFESION, FIRST_NAME, LAST_NAME, DISPLAY_NAME) AS 'STRING' FROM `" . ACCOUNT_TABLE . "` WHERE STRING LIKE ( " . $data_array . " ) AND BUSINESS_POST_CODE LIKE '" . substr(P_BUSINESS_POST_CODE, 0, 4) . "%'"; $q = mysql_query( $query, $CON ) or die( "_error_" . mysql_error() ); if( mysql_num_rows( $q ) != 0 ) { die(); } } Problem is I want to use the temp col 'STRING' in the where clause but is returning 'unknown coloumn STRING Can any one point me in the right direction, regards Phil

    Read the article

  • Implode and remove empty values

    - by binoy
    Hi, I have an array like this $arr = array('name' => 'John', 'address' => 'IInd Street', 'state' => '', 'country' => 'US'); I want to display the values as John, IInd Street, US (ie, If any value is empty, I don't want to display comma and break over there) I could able to display this with the following code $values = implode(',', $arr); echo $str = implode(',<br />',array_filter(explode(',', $values))); Is there any better way to do this ?

    Read the article

  • String useless character strip - PHP

    - by Zoltan Repas
    Hi! I've got a huge problem. I made a special ID for the things in our webpage. Let's see an example: H0059 - this is the special ID called registration number. The last two chars are the things' id. I'd like to cut off the useless characters, to get the real ID, what means strip the first char, and all the 0s before any other numbers. (Example: L0745 = 745, V1754 = 1754, L0003 = 3, B0141 = 141, P0040 = 40, V8000 = 8000) Please help me in this. I've tried with strreplace and explode but failed :( Thanks for the help.

    Read the article

  • php echo json in foreach loop

    - by Vidya Sagar
    i have product ids like this 1,2,3 in $product_ids var $product_ids = explode(',', $product_ids); $product_ids = array_filter($product_ids); foreach ($product_ids as $key => $product_id) { $sth = $this->db->prepare("SELECT * FROM products Where id =:id "); $sth->execute(array( ':id' => $product_id )); $final_data = $sth->fetchAll(); echo json_encode($final_data); } how can i format json whit this code in for loop echo json not working is there any other way plz help

    Read the article

< Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >