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 want to compare each digit of a number array. Like: 5450...i want to compare each of the digit such as: 5,4,5,0 individually with other number.for that i want to convert this number string in number array.how to do this?
you can use str_split to convert the string in to Array
For example:
<?php
$str="5450";
$arr=str_split($str);
print_r($arr);
?>
output:
Array ( [0] => 5 [1] => 4 [2] => 5 [3] => 0 )
You can use preg-split - see example two here: http://us3.php.net/manual/en/function.preg-split.php
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
Hello I had a link...
'process.php?wpn=somevaluehere'
Where I want whatever value place on 'wpn' must get another value from array of values example.
array (
"somevaluehere" => 5,
"somevalue10" => 10,
"somevalue20" => 20
);
then how I can output the array values, been trying to search over google but I failed to find it since I am very new PHP programmer but I learn pretty fast and somehow can understand them. And if it can't be found on the array list, I wish it do nothing.
$values = array(
"somevaluehere" => 5,
"somevalue10" => 10,
"somevalue20" => 20
);
echo $values[$_GET['wpn']];
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 need to get the url or the number (this number is just for example but all the numbers have 7 digits) using regex? It is mandatory not to match all the <a> available in the HTML file, but with this exact structure.
<a href="./view/3049532/">
That's not hard even a little.
/<a\s+href="\.\/view\/(\d{7})\/">/
See demo
<?php
$page_content = <<<THIS
<a href="./view/3049532/">
<a href="./view/398562/">
<a href="./view/3652872/">
<a href="./view/3785471/">
THIS;
preg_match_all('/<a\s+href="\.\/view\/(\d{7})\/">/', $page_content, $matches);
print_r($matches[1]);
Output:
Array
(
[0] => 3049532
[1] => 3652872
[2] => 3785471
)
and also according to others words just use regex if it's your last choice!
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 this array:
array(
(int) 1 => 'igor.cesar#soreq.com.br',
(int) 5 => 'igorpol#gmail.com',
(int) 6 => 'kkk#asasa.com'
)
I want to convert to this:
array('igor.cesar#soreq.com.br','igorpol#gmail.com','kkk#asasa.com')
How can I do this?
You could use the array_values function:
array_values($yourarray);
i would do it like this.
foreach($yourArray as $v)
{
$newArray[]=$v;
}
explanation
for each value of your array put it in a new array called $newArray
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
foreach ($result as $key => $value) {
}
In this can the $value be an object like the following given below ,
where 10 is the key and other is value
[10] => stdClass Object
(
[nid] => 80
[type] => create_an_account
)
Is this valid ??
I would love to make a long answer but I can't develop more than: Yes it is. For your culture, this is extract from the foreach doc:
The foreach construct provides an easy way to iterate over arrays. foreach works only on arrays and objects, and will issue an error when you try to use it on a variable with a different data type or an uninitialized variable. There are two syntaxes:
Before asking on SO, you can try by yourself :)
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions must demonstrate a minimal understanding of the problem being solved. Tell us what you've tried to do, why it didn't work, and how it should work. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
Regexp :
preg_match('#^(\\w+)( | array )(\\w+)(?:|\\=(.*))$#', $line, $mtch)
Text :
integer udg_plc = 0
integer array udg_time
string array udg_plname
player array udg_dlforpl
multiboard udg_LastTable= null
integer array udg_kill1
As a result there is no matches. How to correct?
This is because there are more than 1 space in your input
/^(\w+)( +| +array +)(\w+)(?:| +\=(.*))$/
Use + quantifier to match 1 to many spaces