Tagged Questions
4
votes
2answers
31 views
Loop in form with foreach and session
I have a form with a loop inside.
Here is my code:
<form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post">
<?php
for ($i = 1; $i <= 2; $i++) {
echo "Numero ";
...
1
vote
1answer
24 views
search through array of strings for fuzzy string match
I have two arrays which look like the following:
$arr1 = ("stringType1AndSomeRandomStuff",
"stringType2AndSomeRandomStuff",
"stringType3AndSomeRandomStuff",
...
1
vote
2answers
19 views
php array removing successive duplicate occurances in an array
The question i would like to ask here is:
Is there anyway that i can remove the successive duplicates from the array below while only keeping the first one?
The array is shown below:
...
0
votes
0answers
26 views
webservice not returning a array
I need help with this webservice, it is returning this stdClass Object ( [GETOfertasAereasResult] => )
I need to return an array with all the values.
<?php
try {
$wsdl_url = ...
0
votes
4answers
51 views
How to reverse PHP array after each time it loops
How to do a snake loop in PHP or How to reverse PHP array after each time it loops
I'm not sure what this method or technique is called so I'm just going to call it a snake loop.
Basically what I'm ...
1
vote
1answer
23 views
I am getting an error when inserting with execute($array)
I have a table
percentile int(3) No
FoSW int(3) Yes NULL
dfLR int(3) Yes NULL
FoA int(3) Yes NULL
SoG ...
0
votes
0answers
24 views
PHP json_encode json with variation of array. JSON Sometimes do not appear in firebug as JSON
Does JSON like any specific array structure?
when it is used in
$value['date'][0] = "12-21-2012";
$value['name'][1] = "Joe";
echo json_encode($value);
it seems to detect JSON under firebug
...
0
votes
2answers
20 views
How to creat a nested list from an array PHP
I have a list of awards I'd like to group and list by year. I'm able to list the items, but have been unsuccessful in nesting them.
/////ARRAY
Array
(
[0] => Array
(
[Award] => ...
-4
votes
1answer
33 views
Pushing a single element to an existing array php [on hold]
I know that .push() will push an array of elements to an array, this appending each element to the end of the existing array.
How ever how do you push a single element to an array with existing ...
0
votes
3answers
47 views
Using a Static Class Method to *Quickly* Sort an Array By Key Value in PHP
This question is different than others, as it's focus is on sorting an array with a static class method rather than the typical procedural approach.
I am look for a very performant way to implement ...
-3
votes
2answers
49 views
Make every word in a string into classes [on hold]
I am trying to create an CMS-system where I can add photos to my website, and for the photo-part, I want to have the ability to enter which programs I had used to create that photo.
I should be ...
0
votes
3answers
21 views
PHP Multidimensional Arrays , display data in a tabular form
When I echo the array , result is :
$Items = Array( [147] => Array([ItemName] => Array([0]=>White Snack [1]=>Dark Cookie) [ItemCode] => Array([0]=>IT-WS [1]=>IT-DC ) [256] => Array([ItemName] => ...
0
votes
1answer
9 views
Getting files from a directory and adding them to a zip file
I've created a zip file named 'files.zip'. I have images inside my property_image folder. I've scanned that directory and have the type of files I need. '$prop_image' is another array which have the ...
0
votes
1answer
13 views
Getting Unique Values in Multidimensional Array PHP
I have an array similar to this:
array(5) { [0]=> string(2) "32" [1]=> string(2) "67" [2]=> string(19) "2013-07-15 15:56:28" [3]=> string(1) "1" [4]=> string(4) "Fail"}
array(5) { ...
0
votes
1answer
22 views
Loop through array that might be multi dimensional
I might have the following array()
Array([
0
]=>Array([
part_id
]=>6[
part_user_id
]=>2[
part_department
]=>3[
part_category
]=>1[
part_subcategory
]=>1[
...
0
votes
4answers
36 views
Can i use two quotations with Array()?
I translate my website to French, i would like to know if this is correct
$lang = array(
"tittle" => "C'est bien",
"desc" => "Bienvenue sur mon site",
);
If i use:
'tittle' => 'c'est ...
0
votes
1answer
68 views
array containing two arrays with no key
I was bug squashing my script when I discovered that an array ($array) contained two arrays with no key like so:
array(19) {
["id"]=>
string(3) "243"
["var"]=>
string(4) "test"
}
...
-1
votes
2answers
28 views
Using checkboxes to specify items in array
I want to use checkboxes to specify the items to be added to an array, my code is as follows:
$columns = array(
if (isset($_POST['CustomerID'])) {
'Customer ID' => 'CustomerID',
}
if ...
0
votes
4answers
36 views
get the name of the current $_GET variable [duplicate]
I want to know what URL user has accessed. For example, if user accessed:
index.php?register
it will echo '1'.
if (isset($_GET))
{
switch ($_GET)
{
case "register":
...
0
votes
1answer
18 views
Hierarchal Menu in PHP from Array
Alright, it's hump day, and my brain's already shot.
Can someone tell me what I'm doing wrong here, I'm trying to build a Navigation list properly (hierarchal)
Here's the array:
Array
(
[0] => ...
0
votes
3answers
54 views
Random Value in php
I using the rand from php. That below script is working perfect, But My question is to give the priority for the one value in array(Show multi times). For example 100 times it randomly show the value, ...
-1
votes
4answers
40 views
Creating a repeating integer array - PHP [on hold]
I just want to make an array with the dates of a month. So the dates will start from 1 until 31 at most.
The obvious way, I know is a manual way:
$date_array = array( '1', '2', '3', '4', '5', '6', ...
0
votes
3answers
38 views
PHP error while inserting in MYSQL with arrays
I have a script which inserts all data in array to MYSQL. But when there is just a single word in the array, the script gives no error, while when there are multiple words, it gives a
Column count ...
2
votes
2answers
316 views
Cast object to array - strange behaviour
I am casting an object to array and after that I am unable to access the resulting array by a key.
This is the code
print_r($new);
$new = (array)$new;
echo $new['EPPContactemail'];
foreach($new as ...
0
votes
1answer
22 views
Chunk array by value
how do you chunk array like this below?
array(
[0] => array(
['id'] => '1',
['parent_id'] => ''
)
[1] => array(
['id'] => '2',
['parent_id'] => ''
)
[2] => array(
...
0
votes
6answers
66 views
Inserting values of array into MYSQL
I have a text file, who's value i have put into arrays,
this is the php code:
<?php
$homepage = file_get_contents('hourlydump.txt');
$x = explode('|', $homepage);
$desc = array();
...
1
vote
1answer
43 views
Parse string into multidimensional array with single regex?
I was wondering if anyone here could help me. I have the following string:
$str = 'unit1(field1,field2,field3),unit2(field4,field5,field6)';
I am trying to parse this string to create the ...
1
vote
2answers
51 views
PHP: key->value from two array elements
Basically, I have an array where each element is a key/value pair of elements, like this:
[myArray] => Array
[0] => Array
[id] => 121
[name] => ...
0
votes
1answer
21 views
Issue with call_user_func_array
Having a bit of a problem in combining arrays...this works:
$un[0] = array("0:0:0");
//$un[1] = array("1:1:1");
$flat = call_user_func_array('array_merge', $un);
If I uncomment the ...
0
votes
1answer
43 views
I have a multidimensional array, and need to sort it by a “column” but keeping the other column organized
my array have this structure:
$news = array('id' => '', 'views' => '');
i need to order this by the most viewed, but it have to match the id. I've done some research but got many doubts.
0
votes
4answers
37 views
preg_replace case insensitive using two arrays to replace the first match
I need something like this:
$string = "That's a big apple, a red apple";
$arr = array(apple, lemon);
$arr2 = array(APPLE, LEMON);
preg_replace('/($arr)/i', $arr2, $string, 1);
//output = That's a big ...
0
votes
1answer
28 views
How to access array computer by a function within Codeigniter?
I have a function as follow:
function get_employee_information()
{
$this->db
->select('id, name');
$query = $this->db->get('sales_people');
$employee_names = array();
...
2
votes
1answer
34 views
Get data from array in object with function
I have a function that returns the value of a variable inside an object like so :
public function getVar($var)
{
return ($this->$var);
}
It works fine, but I cannot find a way to get the ...
0
votes
2answers
32 views
Method for comparing array keys and creating MySQL Statements
In a user system we are building, a client is able to sell a number of products that we offer. The number of these products is not too extensive but we may (and plan to add new products often). When a ...
1
vote
1answer
54 views
SET a1 WHERE a AND b1 WHERE b AND c1 WHERE c, etc
I have MySQL Table with images. In my backend app I use live sorting module (drag & drop images).
What I want is to update all sorted images after sorting is done within one query, instead of ...
3
votes
5answers
30 views
Apply logic to only certain keys in array using PHP's foreach
My script outputs an array:
$person = array(
'name' => 'bob',
'age' => '27',
'sex' => 'male',
'weight' => 'fat'
// ...etc.
);
Sometimes the keys in $person have no ...
-7
votes
0answers
38 views
PHP Array sum array values by key [on hold]
I need to make new array with sum same values from key rate and add new key with count sum items. My php array:
Array (
[0] => Array (
[rate] => 4.0000
[amount] ...
0
votes
2answers
20 views
php for loop for an array that takes values from function
I have a function which is returning some values. I want to put those values in an array after checking if the current value exists. I 've written the following code:
...
0
votes
1answer
22 views
php sorter script only outputting the same data even though i am asking it to do diffrent
okay so i have made the following script to sort some data i have in this format
0|1|2
heres my script (this now works)
<html>
<body>
<form method="post">
<div ...
0
votes
1answer
29 views
Get a specific line from object (php)
i get some URLS from HTML site by using
foreach($html->find('source') as $video)
if($video->type =='video/mp4') {
echo $video->src. '<br>';
my ...
-3
votes
1answer
30 views
trying to sort data in text box in php and save to text file
hi there i am trying to create a php script to extract data inbetweeen dilems and save it in a text file
the data is like so
data 0 | Data 1 | data 2 | data 3 | data 4 | data 5 | data 6
data 0 | ...
-2
votes
3answers
49 views
PHP Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource
After uploading the site to my web server I get this message:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource
in ...
0
votes
2answers
36 views
Loop MySQL-Query 10 times for each item in array (PHP & MySQL)
I'm trying to write a Top-10 list with categories but it doesn't work in the way i want it to. There's an array with a dynamic number (n) of items and want to loop each item in this array 10 times to ...
0
votes
3answers
61 views
Formatting url strings PHP array
Hi all I am sorry if this is a dumb question and I understand I might get banned for asking it but after a lot of work reading over PHP manual, reading the relevant chapters in PHP5.3 and scowering ...
-2
votes
5answers
56 views
Separate the nested array and get the value only php [on hold]
I have tried lot unable to get values from the nested array
here is the array:
$array = Array (
Array (20, 21, 22),
Array (20, 21, 23),
Array (20, 22, 23),
Array (21, 22, 23)
);
...
-4
votes
4answers
32 views
Extract all infos [on hold]
Array
(
[CATEGORY_NAME] => Array
(
[0] => test1
[1] => test2
[2] => test3
[3] => test4
[4] => test5
)
...
1
vote
4answers
40 views
PHP sort weekday and month-year array by custom order
I have an array of weekdays (see below) that I would like to sort as "Mon-Tue-Wed-Thu-Fri-Sat-Sun".
"Sun"=>59
"Sat"=>41
"Fri"=>21
"Thu"=>11
"Wed"=>14
"Tue"=>19
"Mon"=>31
I ...
0
votes
1answer
33 views
Overwrite array position
I've gotten somewhat stuck writing a small method to apply product ids and its associated super attribute to an array session.
What i'm trying to do is if a certain attribute set (for example a ...
-1
votes
0answers
28 views
Sort data in array using php and dilems
Basically I want to sort a text file I want to be able to past my data into a text box pick the position of what I want to extract
my data is like so
data 0 | Data 1 | data 2 | data 3 | data 4 | ...
0
votes
1answer
53 views
how to count specific values in php array
Hi i have array like this:
0 =>
array (size=6)
'id' => string '55' (length=2)
'uid' => string '1' (length=1)
'item_id' => string '5' (length=1)
'item_name' ...