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 an php array of 99 numbers.
The array contains the digits 1 to 100 with one digit missing.
How to know the missing number?
Since you say you've found an answer yourself, here is a possible solution
$assignmentArray = array(1,2,3,4,5,6,7,8,10);
// find the missing fie... err.. missing value is actually more correct.
$missingNumber = array_sum(range(1, 10)) - array_sum($assignmentArray);
echo 'The missing number is: ' . $missingNumber;
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 8 years ago.
Improve this question
i have this string
$string = "Social\Notify\Models\User";
How can i tell to php how select just the fourth segment of it? in this case just the word User?
Something like this will do?
$str='Social\Notify\Models\User';
echo explode('\\',$str)[3]; //"prints" User
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
I want a regex that will help me to get the 4 numbers before the cc.
The RegEx must contain the cc to identify these exact number.
Example:
1600cc
You should use:
/(\d{4})cc\b/
\b ensures that "cc" is at the and of the word.
preg_match('/(\d{4})cc/', $string, $match);
$match[1] will contain the number.
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']);