Hi people!
I'm using $key = in_array('setname', $Sname);
echo $key;
To try and echo nr 2 in the array here:
Because I need a script which can give me the position in the array of a specified object, like 'setname'. - Array (
-
[0] => /edit-user
-
[1] => lone
-
[2] => setname
-
[3] => lone2
-
)
But it doesnt work, nothing is echoed. Why is that?
The array is generated from explode(), I hope that doesnt affect it.
Thanks for insight.
9 2135
Well by using - $search=array_search('setname', $Sname);
-
echo "search $search";
It doesn't echo any value except for 'search'.
:/
But if Im testing the manual example quickly: - $array = array(0 => 'blue', 1 => 'red', 2 => 'green', 3 => 'red');
-
-
$key = array_search('setname', $SnameA);
-
echo $key;
-
// gives 2
It works fine.
Could it be because of the array $Sname is generated by an explode?
then "setname" is not in your array.
Lol I tried changing 'setname' in the search to any of the other posted values, and it worked. But only on 'setname' it wont give the array position.
There is no hidden characters so I have no clue why it doesnt echo it.
The array is still as posted up top.
Edit: Heehee well it is a hidden character.
The output is formatted as
/edit-user:lone:
setname:lone2:
So there is a line break before setname.
Still wont show though, even if I use \r\n, \n or nl2br :( Edit 2:
Well well, I guess I will survive if I dont use line breaks for each input, this way it works.
However with line breaks it would be easier to use what im making :(
Thanks though, using array search and it works!
so the line break is part of the string?
well everything is sent from one textarea, and i would like the script to accept line breaks. so that commands could be formatted as:
/edit-user:Name:
setname:NewName:
So yeah, the line break seems to be a part of it when I look into the array, there's a line break before 'setname'.
explode() seperates the : parts.
Ive used this before... I can't believe I didnt remember it lol.
Thanks !
Sign in to post your reply or Sign up for a free account.
Similar topics
by: J. B. Moreno |
last post by:
What's the best (i.e. fastest) way to find out if an array contains a given
value? Other than looping, the only way I know to do it is to use an
associative array/hash instead....
Is there a...
|
by: cai_rongxi |
last post by:
Anyone has the solution to the question "Given an array a with value
1...N, find a repeted value" in C code?
Thanks a lot
|
by: mike |
last post by:
I have ListArray with number in Eg:
1, 1.456, 2.43, 4, 6.78
next i have a decimal variable containing one number EG:
1.786
Could someone please tell me how i find the "closest match" number...
|
by: Arjen |
last post by:
Hi,
I need to add this inside an array:
1 3
2 4
3 2
4 5
5 1
I think of using this:
|
by: Ros |
last post by:
Peeps,
I need help with trying to find a value in array of arrays.
Public Module myModule
Private Site_Access() As Array
Property Set_SA()
Get
Return Site_Access
End Get
|
by: elissa |
last post by:
hi guys i really wish if some one could help me with this problem , well i solved it but the output is always wrong so can some one help me:
the Question is in this link:...
|
by: =?Utf-8?B?VGhvbWFzVDIy?= |
last post by:
Hello,
I have an array that holds 4 values ( they contain random numbers). I would
like to find the lowest value (if there is a tie i would like to find one of
the tie.) then remove that value....
|
by: choke |
last post by:
I need to write a function in devc++ that creates an array of n integers, each element is equal to n*n+i*i-n*i where i is from 0 to n-1 as the array index. Within the same function I need to find...
|
by: raylopez99 |
last post by:
I suspect the answer to this question is that it's impossible, but how
do I make the below code work, at the point where it breaks (marked
below). See error CS0411
This is the complete code. ...
|
by: raylopez99 |
last post by:
I would like to know if there's a quick "Linq" way to find the index
of an array having a particular value. I can do this the long way by
sequential iteration, but would like to know if there's a...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
| |