Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8029969
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T00:36:41+00:00 2026-06-05T00:36:41+00:00

I receive from my MySQL database a multidimensional array Array ( [0] => Array

  • 0

I receive from my MySQL database a multidimensional array

Array
(
[0] => Array
    (
        [page] => categorypropose
        [value] => baby-sitters
        [id] => 357960
    )

[1] => Array
    (
        [page] => categorysearch
        [value] => adéquate pour garder
        [id] => 357961
    )
...
)

In this array, I have some ISO-8859-1 to UTF8 conversion to do via a ‘homemade’ function “loadtext”.

But when I do this :

    $array = $query->result_array();
    foreach($array as &$k)
    {
        foreach ($k as &$value)
        {
                            //Works
            $value = $this->loadtext($value, 'ISO-8859-1');
        }
    }
     //Back to normal as $this->loadtext never existed
     print_r($array);

It doesn’t conserve the changes (When I echo $value, it works, but the modification is not kept at the end …)

EDIT : This is the function loadtext that I am oblige to use (actually, I didn’t make it but I have to use it …)

function loadtext($text,$charset){
    $text = stripslashes($text);
    if($charset!="UTF-8")
        $text = iconv("UTF-8",$charset,$text);
    $text = str_replace(" :"," :",$text);
    $text = str_replace(" ;"," ;",$text);
    $text = str_replace(" !"," !",$text);
    $text = str_replace(" ?"," ?",$text);
    $text = str_replace(" ."," .",$text);
    $text = str_replace(" …"," …",$text);
    return $text;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T00:36:42+00:00Added an answer on June 5, 2026 at 12:36 am

    You could try it like this:

    $array = $query->result_array();
    foreach($array as &$k)
    {
        foreach ($k as $i => &$value)
        {
                            //Works
            $k[$i] = $this->loadtext($value, 'ISO-8859-1');
        }
    }
     //Back to normal as $this->loadtext never existed
     print_r($array);
    

    But better yet, you could try using the MySQL function CONVERT() in your query so that the strings you get back are already in UTF8 format.

    http://dev.mysql.com/doc/refman/5.0/en/charset-convert.html

    At the very least, use PHP’s mb_convert_encoding() instead of your homemade function. There’s no reason to reinvent the wheel.

    https://www.php.net/manual/en/function.mb-convert-encoding.php

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I will be using data from a MySQL database and to receive that data
I receive a variable from the mysql database named $option which in this case
I need to add values received from MySQL into an array (PHP). Here is
I am working on an Asset Database problem. I receive $id from $_GET[id]; I
I am returning results from a MySql database in PHP that I would like
I have a MySQL database, php code to retrieve from the database, and an
I'm trying to download a range of rows from my MySql database, through a
I'm using sessions to receive my info from my database table... But I'm not
Which would be faster in retrieving data from a mysql database? Data split across
Pulling some data from MongoDB and inserting it into a MySQL database, using Python

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.