-
Posts
14,780 -
Joined
-
Last visited
-
Days Won
43
Everything posted by .josh
-
[SOLVED] help turning list of words into an array
.josh replied to Jnerocorp's topic in PHP Coding Help
I have a text file that has like 225,000 words or so. It is exhaustive and includes many things that are not real "words" per se (like, it has names, proper nouns, etc.. and even a couple acronyms I think...) edit: Actually I have 2 files: 1 with the words and one with the words and their part of speech (like "dolphin\N" N = Noun) -
[SOLVED] help turning list of words into an array
.josh replied to Jnerocorp's topic in PHP Coding Help
note: from a text file, you will have the \n (and possibly \r also) newline chars after each word, so you will want to trim each value in the array. You can do all of them in one go using array_map like this: $array = array_map('trim', file('sometextfile.txt')); -
The problem is getting two languages to be parsed in a single file. Off the top of my head I don't think you can really do that, but, perhaps you can get around it by treating it in the same way you would ajax: call the script, the script does the processing and outputs the results as plain text, and on the other end, it is assigned to a var. I don't know perl enough to be more specific with perl syntax, but if we were to look at it the other way around: getting a perl script to be included in a php script, it would go something like this: Let's say you just want it to be executed and aren't expecting anything returned, or else a simple scalar value: <?php $result = file_get_contents('somePerlScript.cgi'); ?> this executes the script and assigns the results to $result. It is "executed" in the same way as if you were to go directly to it in your browser, so $result would contain the same stuff as a rightclick > view source from in your browser. So if somePerlScript.cgi were to do db interaction or whatever and in the end, do like [pre]print 'kitty';[/pre] that would be assigned to $result. If for instance I needed somePerlScript.cgi to set certain variables or whatever, I could have it output the actual code to set the variable, and eval the string, and it will parse the string as if it were php code. I don't know if perl has an equivalent function, though...example: somePerlScript.cgi #!/usr/bin/perl print "content-type: text/html \n\n"; print '$x = 123;'; script.php <?php // somePerlScript.cgi is called and it outputs the following: $x = 123; $result = file_get_contents('somePerlScript.cgi'); // so basically you have the equivalent of this: $result = '$x = 123'; eval($result); // evaluate the string as if it were php code echo $x; // output: 123 ?> So that's basically what you could do, in concept. Just have to do it the other way around, where you are calling a php script in your perl script.
-
No. The DOMDocument is an extension that will take a string (loaded from a file or straight string) and parse it and build a DOM out of the tags in it. It more or less allows you to access/manipulate things in the string in the same way as you can with the DOM built on a rendered page, with javascript. You cannot use javascript functions specifically, but the extension does have methods and properties that mimic a lot of what you can do with javascript (like getElementById, etc...). Also it is important to note that it does not manipulate the DOM "in real time" that is generated on the client - IOW, as usual, php is server-side, and as far as it is concerned, everything that is output to the client is arbitrary text.
-
Okay it's been a long time since "people might have javascript disabled" to be an issue to actually consider. Simply throwing a "you must have js enabled for full functionality" inside a noscript tag is more than sufficient these days. The only "disabling javascript" issuea that should be considered these days is to not do things like validate user input with js (which you'd be surprised how many sites actually do this...), make sure your backend can do what it needs to do for data that would not come in if it happens to be disabled, etc... in short, if you are trying to come up with a strictly php solution to this "feature" solely because "people might have javascript disabled," it's really not worth it.
-
OMG sign of the apocalypse! Yeah that's true. More than plenty of people who refuse to accept an answer or advice given because it involves telling them they need to step back to square one, etc...
-
Exactly. 99% of getting your problem solved is how you present your problem in the first place. It is not a matter of jumping through hoops, telling us how awesome we are so we will give you the time of day. It is a matter of you communicating your problem and showing what you have and haven't done, as well as what you do and do not understand, so that you do not waste people's time when trying to help you. Posting relevant code. It's an easy cop-out to think that noob==don't know relevant parts. I call B.S. on that. If you don't know relevant parts, then you are probably working on a 3rd party script and have no intention of actually learning programming. Or else you need to step back many steps. In either case, if you cannot identify relevant parts of your problem, then you will not understand answers given.
-
well, not exactly...in order to have it reload when the checkbox was checked, you would need js for that anyways. What you are saying would be a link with a var attached to it. That's not quite the same thing. In addition to that, he will then have problems with previously filled out form field info being lost. If you want to strictly do this with php, you could have some kind of "add another" button as a form submit button, so that when you press it, all of the current form info gets passed to the server. Then check for the specific form submit button, echo out new elements based on that, meanwhile echoing out the previously posted info back into the original form fields.
-
I think you are saying you want to dynamically add form elements? Cannot do this with php. You need to do it with javascript.
-
All that aside, you're not really going to get much help on asp and how MS does it, on a php focused board...
-
The problem is many people need fish but have no intention of learning to be a fisher. The common sense solution to that would be to hire a fisher, but either they cannot afford it or else don't want to pay for it. They just want a quick fix or someone to quickly fix it for them, and then move on. Point is, a lot of people do not have any intention of learning to program; they just have this one issue they personally have to deal with. We are not here to cater to those people. We aren't here to cater to anybody, actually. This isn't a business. You guys aren't customers. Whether you go here or some other place makes no difference to us. We have no obligation or responsibility to people. The problem is that many people seem to think otherwise. What I find off putting is the arrogance of some so called 'helpees' who assume that we have nothing better to do with our time than do other people's work for them so they don't get in trouble at work or whatever. This is a free site and all the 'helpers' are volunteers. Our efforts are to teach people to fish, not be their personal fishers, and those efforts are for our own reasons (by helping, we ourselves learn), not because we are somehow obligated. It is not asking too much or being arrogant to expect people to make an effort to research before posting. Seriously, there are a lot of questions that many people ask the same basic thing over and over. Arrogance is assuming you're the first person to ever ask xyz. And then insult us by offering some lame lie about how you did try to google. "Wording it right" is a matter of understanding basic communication, not understanding programming. It is not asking too much or being arrogant to expect people to write legibly. Seriously. You are coming here for help, not the other way around. You are offering nothing in return, nor are you required to give anything in return. Writing legibly enables people to better understand your problem so that we can help you. It is not asking too much or being arrogant to expect certain detail in posts. We have guidelines, stickies, rules, advice for posting, etc.. all over the place. But people don't bother to read them. That's like going to someone's house and they have a big sign posted on their door to take off your shoes before coming in, but you don't bother to take off your shoes. What I find off putting is that they then have the gall to get all mad when we're like wtf take off your shoes! You have the gall to say we are being arrogant by expecting you to know ahead of time, when we go through a lot of effort to plaster shit all over the place in an effort to help you. It is not asking too much or being arrogant to expect people to make an effort to research information given in posts (links to the manual, terms to search, general concepts, etc...). You claim you tried to google and found nothing. Well we point you in the right direction, like a manual entry. You claim you don't understand. What you're really saying is that you don't understand because you aren't interested in doing what it takes to learn, most likely because you just want a quick c/p fix spoonfed to fix this one-time-only problem. We are not here to cater to these people. The problem is that since many people have no intention of actually learning, they expect to be spoonfed. They expect a magic wand to be waved. They expect to be able to at most just c/p something and magically their problem is solved, never have to touch php or programming ever again. That is not what we are here for. We are here to teach people how to be programmers, not do their work for them. The problem is that non-programmers do not understand the discipline and complexity of programming. They think it's simple c/p shit that magically works. You get mad when we scream about not doing simple "common sense" stuff like going through a debugging process before asking a question (did you echo out the var to see if it holds what you expect? etc..), but you do not understand that if you cannot even do that, then you cannot program. How are you supposed to consider 100 different things all working together if you can't even have the foresight to echo out a damn variable to see if it holds what you expect, before asking on some forum? The problem is not that we are arrogant or asking too much. The problem is that too many people don't want to make an effort to actually learn, mostly because they have no intention of learning in the first place. They somehow think it's our responsibility or duty to fix their problem, and they don't read any of the rules or guidelines that are in place to help them get their question answered. Programming is not some simple thing anybody can pick up in a day, or week, or even a year. People equate programming to kung-fu not just because it sounds cool, but because it takes effort. It takes commitment. It takes discipline. The reality is that people who whine and complain about things like "being treated as lepers" for "not saying or doing xyz" do not have what it takes to be a programmer. We do not have issues with noobs who want to learn. The issues come up when it is clear to us they are not here to learn. And even if you really do want to learn, if you can't even do simple shit like learn to write legibly, read rules and guidelines and stickies, research for yourself, etc.. then you are not ready to learn. That's like joining the army because you want to be a soldier, but you get all pissy because the drill sergeant is yelling at you and making you do pushups and run for miles on end and get up at o'-dark thirty in the morning and etc... blahblahblah. You cannot magically be a toughened, skilled warrior w/out the discipline and training. We are here to help make soldiers, not be your personal henchman. We are not obligated to help anybody with anything, nor are we obligated to be "nice" about anything, in the same way businesses are "nice" because in the end they want your money, because we are not a business. General respect for fellow human beings? Well you have to give respect in order to get it. When you come to our site and don't bother to read the rules or make any kind of effort to research, when you post some barely legible vague question, you are not respecting us. You are doing the opposite. 99% of the time our alleged "arrogance" is really a response to your disrespect to us.
-
you can use fopen and fread to read it one line at a time.
-
$words = "Walk Move"; $words = explode(' ',$words); $words = "'". implode("','",$words) . "'"; $sSQL = "select dutch from woordenboek where papiamento1 in ($words)";
-
my guess is if file() isn't an option for you, chances are the other functions available aren't going to be either. Unless you are wanting to read/process the file a different way than how file() does it?
-
What sites can I go to to learn advanced web programming?
.josh replied to optikalefx's topic in Miscellaneous
You can start off by not spreading yourself so thin. If you do not know html and have at least a basic understanding of how css works, I would start there. -
dude are u some way saying that i made up about nasa or something? If so i wouldn mind proving my words. But just a sugestion being staff of a such a wonderful site and behaving like a kid gives bad name to the site. Learn to be polite to users ur behviour may some day cost u alot. No I wasn't saying you made it up. I believe it. I mean look here, you just put my in my place just like that. That means you must be real smart, just like them nasa people. Yep, you definitely have nasa blood in you all right. Thanks for the suggestion!
-
Ask someone at nasa. You've got connections there. I hear they are really smart. They should know.
-
"entire site in one page" is not really idea for real world application, though. There's a reason why MVC exists. When it is just you that is touching virtually everything, hey whatever gets you off, but in the real world, you have many people all working on the site for various reasons. Like for instance, any given client could have a team responsible for nothing but database, another team for nothing but actual server-side coding. Another team responsible for content/creative. Another team responsible for doing things like adding tracking code to things as ad-hoc report requirements come up, etc.. and the point is, when you have tons of people all needing to work on the site, you do not want them to all be accessing the full enchilada, because 99% of the time, the tracking people won't know jack shit about server-side coding. The content people won't know jack shit about ANY coding, etc... and on top of that, many of these teams are broken down into sub-teams, and many of them are not actual employees of the client, but whole other 3rd parties. So you DON'T want to be having to give 100% access to everything to everybody.
-
If you really want to learn, invest in the book in the link. It goes into more detail than you will ever care to know, and then some. It goes into very gritty detail about how the regex engine matches things, backtracks, etc.. blahblah trust me, just get the book.
-
okay so basically you're going to have to have a unique id for each link, and instead of having the link point to the real url, have it point to a single page, with the id attached to the url, and on that page, forward the user to the real url based on that id. Example: pagea.php <a href='controller.php?id=123'>link A</a> <a href='controller.php?id=456'>link B</a> controller.php <?php // example of id & link list. can hardcode it as array or store in a text file or db or whatever $links = array('default' => 'someDefaultPage.php', '123' => 'realpageA.php', '456' => 'realpageB.php'); // get the real url based on the id passed. If it's not in the array, assign a default $dest = (isset($links[$_GET['id']))? $links[$_GET['id'] : $links['default']; // rediret user to real page header("Location: $dest"); exit(); ?>
-
it effectively makes it optional. But technically it is the same mechanics as making a lazy quantifier. Instead of doing it on a "zero or more of this" (.*) or "one or more of this" (.+) you are doing a "one of this" (.?) And even reading it like "0 or 1" 'or' is a logical condition. Look at it in php terms: if (0 or 1) { ... } the condition is evaluated as true if the one on the left is true. php will not even look at the other side of that 'or'.
-
The entire match is always shown in the first array element (element 0). I notice in your OP you have this: echo "!----".$CCM[0]."-----".$CCM[1]."-----".$CCM[2]."----".$CCM[3]."----".$CCM[4]."----".$CCM[5]."----!"; You could just remove it from your echo... Alternatively, you can array_shift $CCM
-
Edit values from multiple rows via a form. Is this possible?
.josh replied to fmpros's topic in PHP Coding Help
This tutorial might be of some help. It's a tutorial about basic database interaction with php. The example database used is mysql so that probably isn't very helpful, but the example script itself is to list rows and columns from a database table and allow you to edit rows, add them, delete them, etc.. so you can see the form and php concept on that count. -
i have no idea what you're trying to accomplish either... you say you don't want to use js because users can disable it. But you say that you want it to change based on what a link source is. Well how is this link source being generated? By js? If so, then you're already using js... with server-side scripting? Well the html output is coming from the server in the first place. What part of your script is generating the html?
-
use session variables.