Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
Im trying to code a php script that will loop a process for each line in a Textarea post. I was wondering if someone can post an example.
foreach(explode("\n", $text) as $line) {
// do something
}
See the manual page on explode()
You might have to use \r\n instead of just \n for textarea (I remember figuring it out for quite a while)
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
In learing mongo with php,I have a tiny problem,
that is all,any help would be great appreciated!
You need to read this MongoPHPQueries Page and probably before that you need to do as #RocketHazmat said and start with this MongoPHP Tutorial.
But here is something that might help you with the data you are trying to find.
$cursor = $collection->find(array("addressse.0.state" => "NY"));
The above will give you a cursor allowing you to iterate over each record that is returned. Hope this helps.
FYI - You need more than just that line above to get that to work. So follow the links.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
OK there is an input field for visitor to enter something in it (like nickname lets say). I wish for (upcoming $_POST) variable to have at least (at least) 4 characters before starts to trigger function.
Here is some cosmetic example..
$inputdata = escapeHTML($_REQUEST['data']);
if($inputdata...)
{
//execute $inputdata
}
Any cool trick? Thx!
if (strlen($inputdata) >= 4)
This should work then
Or
if (mb_strlen($inputdata) >= 4) for non-latin text
Resources:
http://www.php.net/manual/en/function.mb-strlen.php
http://php.net/manual/en/function.strlen.php
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
It's a blank page and that's not how it's supposed to be :/
Can anyone help me out with this?
Code - http://pastie.org/private/9klk5tm6goixq4ev93tkq
-
Mord
You need closing parenthesis on every line that has one opening.
Example:
move_uploaded_file($_FILES["thematicseniorphoto"]["tmp_name"], "uploads/" . $_FILES["thematicseniorphoto"]["tmp_name"];
should be
move_uploaded_file($_FILES["thematicseniorphoto"]["tmp_name"], "uploads/" . $_FILES["thematicseniorphoto"]["tmp_name"]);
EDIT:
Next time use a while() statement and find a pattern of text to search/use. You'll go from 700 lines to like...20.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I suck at regexp but i'd like to just do a simple filter where / is replaced with 1, " is replaced with 2 and < is replaced with 3.
I'd appreciate an example where the syntax would be straight forward, i'd like to run this filter through the input of a get variable provided by the user. A syntax like:
replace(/,1)
replace(",2)
replace(<,3)
.
Thanks.
I really don't see the need for regex here.. You can just use str_replace
E.g.
str_replace('/', '1', $_GET['var']);
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I have text like this Too early to post? http://www.somewebsite.com/article/226973 I want to parse the hyperlinks in the text and make the text look like so Too early to post? http://www.entrepreneur.com/article/226973 I want to do this but I have no idea where to start from or what regexp to use.
$s = 'Too early to post? https://www.somewebsite.com/article/226973';
$parsed = preg_replace('#(https?://([-\w\.]+[-\w])+(:\d+)?(/([\w/_\.#-]*(\?\S+)?[^\.\s])?)?)#', '$1', $s);
echo $parsed;