0
votes
2answers
29 views

PHP load txt file as an array [duplicate]

I have a text file (id.txt) that looks like this: Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 [5] => 6 [6] => 7 [7] => 8 [8] => ...
-2
votes
3answers
38 views

PHP: Issue combining sub-arrays into new array

Working on a poll script, but I have little problems with the options of a poll, creating a new array of it. The actual example array contains 3 sub-arrays with options, sum of votes and percentage: ...
1
vote
3answers
25 views

PHP/PDO how to insert a FOR loop in the execute(array) definition?

I am developing an Android App and I have to write my own API in php. Unfortunately, I have very little experience in PHP/mysql and API's so Im struggling. I dont know how many pictures Im going to ...
1
vote
6answers
40 views

Reading PHP array using key value

I have an array that I'm creating inside my PHP script, the var_dump function gives me this value :var_dump($arrayOfValues); array(3) { [0]=> array(2) { [0]=> string(12) ...
0
votes
3answers
40 views

How can I access an array dimension, based on another array?

Using the following code: <?php $array = array( array( array('a','b'), array('c') ) ); $location = array('0','1'); $text = 'd'; ?> How can I achieve the following, ...
0
votes
2answers
46 views

query post with custom field value in Array

my custom field vardump() for a post with a good value (12 ) is : Custom_field = array(1) { [0]=> int(12) } and my args for my query is : $artistArg = array( 'numberposts' => -1, ...
0
votes
1answer
32 views

How to pass 2 array in json from php and how to parse it in android

I am creating the android application to communicate from android device to my localhost server. I want to pass two arrays from php file to android. But I don't know how to do that. Please help me for ...
0
votes
1answer
49 views

Find out number of array occurrences in php

this answer maybe on google but i couldnt find it because i dont know the exact keywords for this. The situation is as follows. I have an array called $value that contains 2 types of arrays: [12] ...
0
votes
1answer
27 views

structuring the array in required way while using jqplots

I am using jqplot to show data in a graph.I am able to fetch data in the array ,but I have a small problem to plot data the format is [["Pens",10],["Pencils",30],["Erasers",40],["Charts",3]] I am ...
0
votes
2answers
36 views

how to handle this: Get all rows with the same email address, operate on ids, email them once

Honestly, I do not even know how to ask this question since I also do not have any plan on where to start. Say I have the following in mySQL: id | URL | email | ---|------------|---------| ...
1
vote
5answers
51 views

Problems decoding returned JSON data as an object

Im not sure how to exactly get values (access objects and show them on page, or store as variables, etc. just I want to get those IDs (9473, 5649, 7953 .......) from JSON output. Adding the URL which ...
1
vote
4answers
41 views

Javascript json_encode > JSON.parse() array

I the following PHP code: echo "<img src='../images/edit.png' onclick='showEditDiv(" . json_encode($row) . ");'>"; Here is the HTML result: <img src='../images/edit.png' ...
0
votes
2answers
40 views

PHP search item in 2nd level of associative array and delete it

I have an associative array: array( '0' => array( 'id' => 1, 'name' => 'one' ), '1' => array( 'id' => 4, 'name' => 'two' ), '2' ...
1
vote
4answers
45 views

PHP parsing a string and covert to array

I have the following string in php: $str = '/something-new/:id/goto/:new_id/full/page/:num/'; and i need to parse that string and convert it into an array like this: $arr = array([0] => ...
-1
votes
0answers
42 views

foreach use value from array in object

I'm trying to use a foreach loop with array and use those items in object (not sure if it is possible and not sure what to google for). This is my code: <?php $array = array( ...
0
votes
0answers
25 views

PHP, How to customize the serialization of an array of dates using JSM Serializer (or Symfony Serializer)

I need to serialize an array of dates (just that, not an object containing the array of dates!) and I want to be able to control how it is done: $serializer = SerializerBuilder::create()->build(); ...
0
votes
1answer
46 views

Value is empty in PHP Array

I am developing an Instagram application. Nevermind, my questions isn't focused on the API. Its a simple php question. However. Everytime I try to run the the output is that the TOKEN is empty. ...
1
vote
1answer
30 views

How to divide array in parts with a token?

I have an array foreach ($infos->find('.products-list-item .products-list-item__sizes') as $sizes_info) { while($size = $sizes_info->children($k++)) { $sizes_arr[] = ...
0
votes
0answers
33 views

A fast way to write (=>) and (->) characters in php arrays and object attributes?

I recently moved to program in PHP using Netbeans IDE, I found it tedious and time consuming while writing PHP arrays and object attributes using combinations of keyboard keys ("=>") and ...
2
votes
5answers
63 views

Return php for-each output as an array

For given foreach loop output is display using echo $output = array(); $counts = array('45','55','75','95'); foreach ($counts as $count) { $output= $count + 10 ; echo $output } it ...
2
votes
2answers
55 views

How to keep only certain array value, multiple needles php

This one is bit tricky , I have an array and I need to keep only certain value string inside of it $getpositions = file("index.php"); $searchpoz = array('NEED1', 'NEED2', 'WANT THIS ALSO','ANDTHIS'); ...
0
votes
0answers
37 views

Filter special characters, least '/'

I have some fields that are sent to an alert box in JavaScript (the one command that performs the AJAX post or get method) What happens is that in every field I have a JavaScript function that ...
0
votes
0answers
44 views

How to put a lot of information in the class?

I have such a problem: I'm parsing a lot of html files with Simple HTML Dom Parser, that's why I need to use three 'foreach's to parse the nescessary information from it -> I am getting a lot of ...
1
vote
2answers
19 views

Reduce an array to only the User object - Laravel

The Route where I want to retrieve information about a User with id 6 Route::get('/', function() { echo '<pre>'; var_dump(User::find(6)->where('person_id' == 1)); ...
1
vote
2answers
38 views

How to display a readable array - Laravel

After I write: Route::get('/', function() { dd(User::all()); }); And after I refresh the browser I get an unreadable array. Is there a way to get that array in a readable format?
0
votes
2answers
37 views

How to echo multidimensional array using few codes?

i have two scripts. One is named as index.php and other is home.php. index.php is used for login (verification of username and password using in_array) and then redirecting user to home.php. Here is ...
0
votes
1answer
29 views

Check whether all values in an array are equal to X number in PHP

i didnt know how to title this topic so sorry about any misunderstandings. I have an variable called $value that generates something like this: Array ( [0] => Array ( [id] => fieldset-1 [class] ...
0
votes
1answer
23 views

Array seems to drop first element

I make a request to a database and get the following data from it: array(5) { [0]=> object(stdClass)#39 (3) { ["route_id"]=> string(4) "1103" ["route_date"]=> string(10) "2013-12-24" ...
4
votes
7answers
53 views

PHP array values in a sequence [on hold]

Hi i am retrieving values from my database to my web page. here is my code foreach ($rows as $r) { echo $r->title; } Now I want all my title values to be saved in a single variable ...
0
votes
2answers
22 views

php loop through array with duplicate index

I am trying to loop through an array with duplicate indexes. But it only prints 3 times not all of them. I want to print all values in the array is that possible? Here is my PHP code: ...
0
votes
3answers
32 views

array from post into a single mysql row

I have an array that is built based on dynamic rows that changes every time. I am able to post the array but i get each field in a separate row. How can i insert the array into a single row. Here is ...
1
vote
1answer
41 views

Finding out the position of a particular key inside an array

I have created a class to find out the position / level of a particular key inside an array. I was actually trying to create a function but I ended up creating an entire class as I had to keep track ...
4
votes
2answers
60 views

How to expand a string with PHP, using the FROM and TO numbers specified within square brackets?

Let’s say I have the string http://www.example.com/images/[1-12].jpg. I would like to expand it into: http://www.example.com/images/1.jpg http://www.example.com/images/2.jpg ...
0
votes
2answers
36 views

Compare the data of two arrays using foreach PHP

I'm currently trying to compare the data of two arrays against eachother. My code looks something like the one below: foreach ($arrayOne as $one) { $variable = $one['one']; foreach ($arrayTwo ...
1
vote
2answers
56 views

Storing an array in a session

So I'm trying to store an array in a session, but instead of making it an array it just counts everything up all the time! I just want the value that is done in the session, so I can check if the ...
2
votes
1answer
28 views

How do I change a paragraph into an array in PHP including the spaces and punctation

I have a string like this Hello? My name is Ben! @ My age is 32. I want to change it into an array with all words, spaces and punctuation as separate entities in the array. For example if I did ...
3
votes
3answers
42 views

Type hinting - specify an array of objects

How can I specify the argument type as an array? Say I have a class named 'Foo': class Foo {} and then I have a function that accepts that class type as an argument: function getFoo(Foo $f) {} ...
0
votes
3answers
23 views

Iterations in a while->fetch loop not working

I have a function that extracts the details of an item in a database, and adds it to an array before returning it. Currently, i am trying to query the filepath of any images related to the item and ...
0
votes
2answers
48 views

Function calls itself, is this possible?

I've been looking around the internet trying to learn more about sanitization an validation in PHP and it's the second time I run into this type of function that I have some trouble understanding how ...
-2
votes
1answer
49 views

merge Array using Function in PHP [on hold]

I am new to PHP programming and i want to do this functionality using php coding style. I have a two integer array and i want to merge it in to a single array without using any built in php ...
0
votes
3answers
40 views

call to a member function execute() on

Having trouble with line 27, Don't quite know why as I am very new to PHP/MySQL. Was wondering if anybody can advise me why I am getting the error; "Fatal error: Call to a member function ...
0
votes
1answer
44 views

PHP Count Showing 2 Elements in Array, For Loop Loops 4 Times

I have an array that I want to loop through. Using: echo count($places); I get a value of 2. Similar print_r the array gives 2 items. However, when i run a for loop it seems to go through 4 ...
0
votes
1answer
19 views

Accessing Object Properties (Drilling down without array conversion) [duplicate]

I have recently been working with tv_grab_uk_rt which generates a TV guide xml file. I have written a script to convert the XML into an object which I can the loop through and insert into a database. ...
1
vote
0answers
39 views

array store in CodeIgniter sessions

i am calling a controller with method setActiveId and store 1 array in session and display after storing by using var_dump($this->session->all_userdata()) it shows perfactly but in same ...
0
votes
4answers
49 views

Print a variable outside foreach loop [on hold]

Hi friends i need to print a variable outside a foreach loop, but i don't know i can do it. There's someone how can help me?This is my code.Check it out if(is_array($arrayValues2) && ...
0
votes
2answers
58 views

Array into mysql row

Hello i have a dynamic form that can change field names upon user selection. i would like for the form result to be inserted into one mysql row.. i create an array as follows: <?php ...
-1
votes
5answers
37 views

How to get query result into an array in PHP

I have written a query on database the result is given in this form Apples-100 Grapes-200 Oranges-50 Bananas-30 now i need to store the data in an array like this ...
3
votes
9answers
78 views

Array sort by First Value

This is my current Array Array ( [0] => [10,13], [1] => [11,15], [2] => [12,7], [3] => [1,0], [4] => [2,0], [5] => [3,0], [6] => [4,0], [7] => ...
0
votes
3answers
50 views

Using form method POST to an existing PHP array

Using the following form to POST to the same page upon clicking submit: <form action="" method="post"><a class="buttonnohover"> Enter URL: </a><input type="text" name="term2" ...
0
votes
1answer
32 views

php foreach iteration over object property array not incrementing the value

Please help! I have been staring at this for too long. I have a property of an object that is an array of objects. I want to pass in an object to a method of the parent object and search through that ...

15 30 50 per page