php


Array to string conversion is not working in opencart?


Actually I want to convert array data to string data for that I
amusing implode() function by comma separator but it is throwing error.
Below is my code:-
$total_data = array();
$category_return = $this->model_catalog_category->category_name_get();
//print_r($category_return);die;
foreach ($category_return as $total) {
$total_data[] = array(
'category_id' => $total['category_id'],
'parent_id' => $total['category_id'],
'name' => $total['name']
);
}
$data = $total_data;
//print_r($data);die;
$fields = implode(',',$data);
echo $fields; die;
Try this:
$total_data = array(
array(
'category_id' => 2,
'parent_id' => 1,
'name' => 'First Cat'
),
array(
'category_id' => 1,
'parent_id' => 0,
'name' => 'Parent Cat'
),
array(
'category_id' => 3,
'parent_id' => 2,
'name' => 'Parent Cat3'
)
);
$output = implode(",", array_map(function($a) { return implode(",", $a); }, $total_data));
print_r($output);
Output:
2,1,First Cat,1,0,Parent Cat,3,2,Parent Cat3

Related Links

can use httpClient in Android Studio?
Reverse routing in Lumen. Call Router by it's name
Uber Uploader XML ERROR: XML_ERR_NAME_REQUIRED at line 1 with hwdMediaShare
PHP Gearman Worker / Client does not work
Composer, class within my package is not being autoloaded in application using it
How to match any characters without space and don't array usefull things
How do I optimize memory usage in PHP for this function?
Using php file_get_contents() does not work when using ajax
GROUP BY selection with filling up missing times
Get value of an multidimensional array [duplicate]
Calling C/C++ library function from PHP - How to send a -std=c+11 to compiler
if an array default is true, how to display his content?
JSON array containing an image stored as a blob
highcharts php array unset/reset keys after sorting
Count group by in laravel
Why php function doesn't work inside second <?php ?>

Categories

HOME
spring-data
ontouchlistener
cucumber
workflow
bots
activex
message-queue
initialization
out-of-memory
iverilog
informatica
mongoid
tcp
mathematical-optimization
navigation
ipv6
capistrano
angular-meteor
phpseclib
telegraf
tfs2010
heuristics
scrape
cname
grocery-crud
outlook-restapi
async-await
vmware-workstation
nest-api
uima
pst
coreldraw
gollum-wiki
qa
candlestick-chart
ini
eclipse-emf
cell
animated-gif
jpa-2.1
introspection
miniprofiler
sparkle
guice
wampsharp
android-collapsingtoolbar
devtools
busboy
python-sounddevice
best-buy-api
classnotfoundexception
hypothesis-test
pyttsx
flume-twitter
nothing
sonicmq
hibernate-ogm
sequence-diagram
freshdesk
pen
mongodb-aggregation
portability
swiperefreshlayout
mpmovieplayercontroller
business-rules
dymola
nitrousio
ternary-operator
nsrunloop
spring-mongo
openseadragon
cdo.message
rails-engines
vaadin4spring
distributed-cache
miniconda
google-maps-api-2
wso2ml
blockquote
textscan
phpredis
camus
python-c-extension
mutators
debug-symbols
baseadapter
operands
lifetime
symja
otl
forceclose
nodeload
pageviews
air-native-extension
usb-flash-drive
armv6
strcmp
visual-c++-2005
progress-db
rautomation
libxml-js
ofstream
coordinate
thejit
platform-independent
asio
haiku
tablet-pc
css-friendly
asp.net-mvc-views
cleartype
jvm-bytecode
word-automation

Resources

Encrypt Message